Hi, I'm looking for a way to truncate the value of a decimal field type question to 2 decimal places. I've tried Google search but it seems like all I can find is methods of rounding..
For e.g. I get a number from a calculation that is 1.1495. I would like to have another field with a calculation truncate this to 1.14, not round it to 1.15. Is there a truncate formula available for xlsforms?
The values I get could range from 1.0 to 1,000,000.0 so I don't think I would be able to use concat().
Thanks for your help!
Solved! Go to Solution.
Something like this could work.
round(${question_one}-0.005, 2)
Something like this could work.
round(${question_one}-0.005, 2)
Thank you for your response! I think this would work if the initial value from the calculation field was always 3 decimals; however the value could range anywhere from 0 decimal places to 5+ decimal places.
OR, I might need to do some testing to see if this would give consistent results for values with more than 3 decimal places. Thank you again
It should work for all floating numbers for rounding down to 2 decimal places. Let me know if there is any concern.
e.g.
15: (15-0.005)= 14.995= 15.00= 15
15.99925: (15.99925-0.005)= 15.99425= 15.99
Thank you for your response! Unfortunately inputmask doesnt work on web forms, and I dont think regex would work if the value is automatically coming from a calculation in another field rather than being manually entered by the submitter...