alteryx Community

# Alteryx Designer Desktop Discussions

## Keep two decimal places after the decimal point

8 - Asteroid

Which function is to keep two decimal places after the decimal point？

I try round and SmartRound, It doesn't seem to be working.

2 REPLIES 2
13 - Pulsar

Sounds like round should be the right function. Make sure you're using 0.1 as the parameter to round to the nearest hundredth.

You should also be able to use the fixed decimal data type as an alternative if you desire.

13 - Pulsar

Hello @phoebe_90

The approach @JamesCharnley mentioned will work in most cases, however depending on the number of decimal places, there are edge cases where a simple round() function will not work. This is because the round() function looks 1 decimal place to the right of the number of decimal places you specify in the function. For example:

12.1256 rounded to 2 decimal places would give you 12.13 because the value of the 3rd decimal is >=5
12.1246 rounded to 2 decimal places would give you 12.12 because the value of the 3rd decimal is <=5, even though the last decimal is a 6

Attached is a way around this.

Labels