November 6, 200916 yr I have a calculated field that makes up part of the body of an email. It looks like this: "Total new charges:" & $InvoiceTotal When this prints, if the invoicetotal is 79.90, it prints 79.9. If the invoice total is 79.00, it prints 79. How can I get it to always print with 2 decimal places?
November 6, 200916 yr I use a calculation by Comment which allows the most flexibility and control possible. You can specify the precision, currency, separator etc: [color:blue]Let ( [ // USER DEFINED: input = numberfield ; precision = 2 ; currency = "$" ; separator = "," ; decPoint = "." ; // DO NOT MODIFY FROM THIS POINT ON inputRound = Round ( input ; precision ) ; Amt = Abs (inputRound ) ; Dollars = Int ( Amt ) ] ; // PREFIX Case ( inputRound < 0 ; "-" ) & currency & // BILLIONS Choose ( Dollars < 10 ^ 9 ; Right ( Div ( Dollars ; 10 ^ 9 ) ; 3 ) & separator ) & // MILLIONS Choose ( Dollars < 10 ^ 6 ; Right ( Div ( Dollars ; 10 ^ 6 ) ; 3 ) & separator ) & // THOUSANDS Choose ( Dollars < 10 ^ 3 ; Right ( Div ( Dollars ; 10 ^ 3 ) ; 3 ) & separator ) & // UNITS Right ( Dollars ; 3 ) & // FRACTION Choose ( precision < 1 ; decPoint & Right ( 10 ^ precision & Amt * ( 10 ^ precision ) ; precision ) ) ) You will not use it only once but many times when this type of need arises. :wink2:
November 30, 20178 yr LaRetta Thank you so much for this. I have been hunting for an answer to correctly entering the result of a calculation for an Invoice total into an eMail for SO long and I stumbled across your calculation which just works. You are a star!
Create an account or sign in to comment