How to dynamically change decimal places in a report

Hi all,

I have displayed some real number fields in the report.

Now I hope that when the unit is CBM, the corresponding fields will be kept to 3 decimal places, and when selecting other units, only 2 decimal places will be kept. Even if the last decimal place is 0

image

The unit field and number field are independent.

How can I dynamically change the decimal places of real numbers in a report?

Any suggestions would be appreciated.

In the first step, learn how to set a number format dynamically. Use an expression like =Format(Fields!MyField.Value,"0.00") for the value of the numeric field.

In the second step, use IIF() to evaluate the condition (unit is CBM) to use “0.00” format if so and “0.000” otherwise.

Note that I wouldn’t hard-code the logic about CBM unit in the report. I would rather do it in an RDP class and expose just a flag (to use/not use the special format) to the report.

1 Like

It works. Thank you very much for your help