Thursday, 28 March 2019

Dynamically change decimal places in Crystal Reports

In this post, I will explain how to dynamically change decimal places in Crystal Report. To explain this I have created a sample table and sample crystal report in my example.

tbl_Sample contains a column id, decimalPlaces and Amount. 

Dynamically change decimal places in Crystal Reports

I want to format the Amount in crystal report as per the value of decimalPlaces. If decimalPlaces value is 3 then formatted Amount will be 123.256.

In the sample crystal report I added tbl_Sample as Datasource and designed crystal report as per below image.

Dynamically change decimal places in Crystal Reports

Steps to Dynamically change decimal places in Crystal Report

1. Right click on "Amount"

Dynamically change decimal places in Crystal Reports

2. On "Format Editor" window, click "Customize" button

Dynamically change decimal places in Crystal Reports

3. On "Custom Style" window, Click "X2" in front of Decimals

Dynamically change decimal places in Crystal Reports

4. On "Format Formula Editor" window, drag decimalPlaces field from report field to editor and click "Save and close" button

Dynamically change decimal places in Crystal Reports

5. Back on "Custom Style" window, Click "X2" in front of Rounding

Dynamically change decimal places in Crystal Reports

6. On "Format Formula Editor" window, drag decimalPlaces field from report field to editor and click "Save and close" button

Dynamically change decimal places in Crystal Reports

After doing all these changes to Amount field you will get a below result

Dynamically change decimal places in Crystal Reports

0 comments:

Post a Comment

Please do not enter any spam link in the message box.