August 3, 201015 yr I have a calculation field that needs to be rounded to two decimal places. I have tried rounding the calculation field itself as well as formatting it in a Send Mail script step, doesn't work anywhere. Calculation result is Number. Calculation field [color:blue]Round ( Sum ( Accessions::calTotalCharges ) ; 2 ) Send Mail script step [color:blue]Round ( Projects::calTotalCharges ; 2 ) Replacing the field reference with a number, it rounds fine. Can I not use ROUND with a field reference?
August 3, 201015 yr Author The calculation is correct, just not the way it is displayed. The calculation field in the Send Mail script does not round to two decimals. 126 instead of 126.00 432.5 instead of 432.50 I can use a field and format it, but cannot use in a email script.
August 3, 201015 yr Rounding is a numerical operation, and the results you show are correct: a number does not have trailing decimal zeros. What you want is not (only) rounding, but formatting, e.g. = Let ( r = Round ( Sum ( Accessions::calTotalCharges ) ; 2 ) ; Int ( r ) & SerialIncrement ( ".00" ; 100 * Mod ( r ; 1 ) ) ) The result type needs to be Text. Note that the above assumes non-negative numbers.
August 3, 201015 yr Try... Let([ number = 123; rounded = Round(number;2); integer = Int(rounded); decimal = rounded - integer; point = Case(decimal = 0; "."); decimalDisplay = Left(point & decimal & "00";3); result = integer & decimalDisplay ]; result ) Edited August 3, 201015 yr by Guest comment's is, as par, more elegant.
Create an account or sign in to comment