• Javascript
  • Python
  • Go

Crystal Reports Formula: Extracting Decimal and Non-Decimal Parts

Crystal Reports is a powerful tool for creating and managing business reports. One of its most useful features is the ability to create form...

Crystal Reports is a powerful tool for creating and managing business reports. One of its most useful features is the ability to create formulas that can manipulate and extract data from your reports. In this article, we will explore one such formula, the Decimal and Non-Decimal Parts formula, and how it can be used to extract specific values from your data.

First, let's understand what the Decimal and Non-Decimal Parts formula does. As its name suggests, it allows you to split a number into its decimal and non-decimal parts. This can be useful when you have a number that contains both decimal and non-decimal values, and you need to extract and use them separately.

To use this formula, you will need to have a number field in your report. You can create one by simply dragging and dropping a number field from your data source onto your report. Once you have a number field, you can apply the Decimal and Non-Decimal Parts formula to it.

The formula has two parts, the Decimal Part and the Non-Decimal Part. The Decimal Part, as the name suggests, extracts the decimal portion of the number. This can be useful when you need to perform calculations that only involve the decimal portion of the number. The Non-Decimal Part, on the other hand, extracts the non-decimal portion of the number. This can be useful when you need to work with whole numbers only.

Let's look at an example to understand this better. Imagine you have a report that displays the sales data for a company. The sales data includes the total sales for each product, and the total sales for the company as a whole. The Decimal and Non-Decimal Parts formula can help you extract the decimal and non-decimal portions of these numbers separately.

For example, if the total sales for a product is $2,345.67, the Decimal Part formula will extract the value 0.67, and the Non-Decimal Part formula will extract the value 2,345. This can be useful if you want to display the total sales in dollars and cents separately.

Similarly, if the total sales for the company is $1,234,567, the Decimal Part formula will extract the value 0, and the Non-Decimal Part formula will extract the value 1,234,567. This can be useful if you want to display the total sales in millions and thousands separately.

Now, let's see how to apply the Decimal and Non-Decimal Parts formula in a Crystal Report. First, you need to select the number field that you want to split into its decimal and non-decimal parts. Then, right-click on the field and select "Format Field." In the Format Editor, go to the "Number" tab and click on the formula button next to the "Display String" field. This will open the Formula Editor.

In the Formula Editor, you can enter the Decimal and Non-Decimal Parts formula. The syntax for the formula is as follows:

{@Decimal Part}(number) - This will return the decimal portion of the given number.

{@Non-Decimal Part}(number) - This will return the non-decimal portion of the given number.

In our example, we would use the formula {@Decimal Part}( {SalesData.TotalSales}) to extract the decimal portion of the total sales for a product. Similarly, we would use the formula {@Non-Decimal Part}( {SalesData.TotalSales}) to extract the non-decimal portion.

Once you

Related Articles

Crystal Reports for ASP.NET MVC

Crystal Reports for ASP.NET MVC: The Perfect Combination for Efficient Data Reporting In the world of web development, data reporting is an ...