Using two functions together
I'm trying to return some value's as a percentage, which I need to print rounded up or down to 2 decimal places.
I can round the value's with ([Round([Value],2)]%) or truncate them with ([Truncate([Value],2)]%)
Can I use Round and Truncate in the same command, to ensure my value's return to 2 decimal places and round up/down accordingly?
Truncate is a custom function I'm using to ensure trailing zero's are not omitted.
Thanks
This discussion has been closed.
Comments
Hello!
It is possible to call functions nested within a single expression (provided the argument types match, for example, `Func2(Round([Value], 2), 2)`), but in your case there is no need to nest `Truncate` within `Round`: `Round([Value], 2) returns a number (decimal/double), which by its very nature does not retain trailing zeros such as .50.
The cleanest way to format the result of Round into a string with two decimal places, or to set the format on the TextObject itself, is:
[Format(‘{0:0.00}%’, Round([Data.Value], 2))]Alternatively, leave the expression
[Round([Data.Value], 2)]as it is and set Format -> Number (DecimalDigits = 2) in the TextObject’s properties.