This site uses different types of cookies, including analytics and functional cookies (its own and from other sites). To change your cookie settings or find out more, click here. If you continue browsing our website, you accept these cookies.
Hello-
I am looking for a way to format numbers so they have two decimal places but only if they are not a whole number. I can't seem to find a way. Any ideas?
Current | Desired |
16 | 16 |
15.75111 | 15.75 |
7 | 7 |
8.99 | 8.99 |
10.22222 | 10.22 |
8.991 | 8.99 |
16.1 | 16.10 |
Thanks,
Steve
Solved! Go to Solution.
Use a rounding formula in a Formula tool to get to your two decimals: Round([Current],0.01) <-- This will round to the nearest hundredth.
Then make sure your field is a double data type, which will show the two decimals when not a whole number, but only the number itself if it is a whole number. 🙂
Cheers!
NJ
Assuming a string data type is an acceptable output:
REGEX_Replace(ToString([Current], 2), "\.00$", "")
The ToString will format with two decimal places. The Regex will trim 2 trailing 0s
Thank you both. NJ, this is exactly what I was looking for!
Steve
I tried this way and it doesnt work when I placed the formatted data into a table report, the .00 decimals re-appears.
Any other ways to achieve this?
I dont want to convert to string as I want my output as a number format.