hal9000 Posted November 6, 2009 Posted November 6, 2009 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?
LaRetta Posted November 6, 2009 Posted November 6, 2009 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: 1
hal9000 Posted December 5, 2009 Author Posted December 5, 2009 Great -- that works like a charm! Thanks!
OneRedmouse Posted November 30, 2017 Posted November 30, 2017 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!
Recommended Posts
This topic is 2562 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