Skip to Content
0
A B
Sep 16, 2019 at 08:00 AM

How can I automatically report correct decimal place?

62 Views Last edit Sep 16, 2019 at 09:26 AM 2 rev

Hello everyone,

I am rather new in Crystal Reports but am starting to get a hang of it.

I am currently trying to get my report to show the correct amount of decimal places for the reported result plus the uncertainty. The uncertainty is displayed right behind it but I want the uncertainty to always show the number of decimal places depending on the power of the result.

Examples correct:

1.2E1 +- 3E0

1.2E1 +- 3.4E1

Examples incorrect:

1.2E1 +- 3E1

I think you know what I mean. If it is of the same power, then it should have the same amount of decimal places. If the power of the uncertainty is smaller, then it should have less decimal places.

For this to work, the power of the result also needs to be adjusted. If the power of the result is x and the power of the uncertainty is x-2, then the result needs to have two decimal places for the uncertainty to be able to be displayed correctly.

Example:

1.2E2 +- 4E0 needs to be converted to 1.23E2 +- 4E0.

In VBA etc. I would use the If Then syntax but I am not sure what the correct variables and the correct syntax would be in Crystal Reports.

The current code is

IIF ({V_SP.RESULT_PRECISION}
< 0 ,IIF ( {V_SP.NRESULT}<{V_SP.DETECTIONLIMIT} ,"",{%Result_SCIENTIFIC}
+ " ± " + {%Error_SCIENTIFIC}), {V_SP.SRESULT} )