Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.

Keep two decimal places after the decimal point

phoebe_90
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
JamesCharnley
13 - Pulsar

Hi @phoebe_90 

 

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

 

JamesCharnley_0-1680092736746.png

 

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

gautiergodard
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