Dan N Posted August 3, 2010 Posted August 3, 2010 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?
Dan N Posted August 3, 2010 Author Posted August 3, 2010 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.
comment Posted August 3, 2010 Posted August 3, 2010 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.
David Jondreau Posted August 3, 2010 Posted August 3, 2010 (edited) 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, 2010 by Guest comment's is, as par, more elegant.
Dan N Posted August 4, 2010 Author Posted August 4, 2010 Comment, That did it, thanks for your quick (and helpful) response! Dan
Recommended Posts
This topic is 5283 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now