How to Vary the Number of Decimal Places Reported


This example will show how Options can be used to vary the number of decimal places when reporting a numeric value.

Normally, a numeric value will be reported with a fixed number of decimal places as defined in the template. This can be done by referencing the Header directly, which will use the ‘Decimal Places’ setting defined for the header in the Model. Or, an expression using a function such as text() or fixed() can be used to display the value to some other number of decimal places:

              

For this example, we will use a Project Option to control and vary the number of decimal places used to report Moisture Contents.

First, we will add a ‘MoistureContentDecimalPlaces’ Option header to a ProjectOption Group. We will make it an integer data type (you could also use a picklist to restrict the use of only certain values).

      

In our template, we will add an Expression that references the Project Option. We will use the text() function and plug the Project Option into the format argument. If a Project Option is not entered, a default of 1 Decimal Place will be used:

text([MoistureContent.MoistureContent],'F'+text(if(isblank([ProjectOptions.MoistureContentDecimalPlaces]),1,abs([ProjectOptions.MoistureContentDecimalPlaces]))))

We can then test this out and see that the number of Decimal Places varies depending on the Project Option entered: