How can I limit the number of decimal places that show in a computed field?
The computed field is an "Integer" Data Type. The Computed FIeld Formula multiplies data entered in another field that is a "Float" Data Type (limited to 2 decimal places) against a conversion rate. For some reason the resulting number as many as 15 decimal place (ex., 1208.024000000000000). I would expect it to either not have decimal places (based on the Integer data type of the computed field) or have 2 decimal places (based on the field it is pulling data from).
I tried converting the computed field to a Float Data Type because I can limit the decimal places on those, but I get the attached error when I try to do that. Keeping it as an integer, the only option I know of is to limit the field length, but that would not limit the number of decimal places consistently.
Solved! Go to Solution.
Solved by broepke. Go to Solution.
You can round the result right in the computed field. This is an example I had...
(round(QUOTED_PRICE - ACTUAL_COST, 2))
Hope that helps.
(the red is the field names and a little math)
Yes, round(v numeric, s int) should address your needs as Brian outlined. For future reference, PostreSQL's math functions are documented here. http://www.postgresql.org/docs/9.3/static/functions-math.html
If you wish to not round out every digit to nearest value, you may consider using NUMERIC(precision, scale) for numeric types as outlined here. NOTE that scale of 0 represents an integer. http://www.postgresql.org/docs/9.3/static/datatype-numeric.html
Hope this helps too,