Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

Alteryx Designer Desktop Discussions

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

Round 130.3155 to 3 decimal places....

craigja
8 - Asteroid

Sounds simple yeah?  130.3155 rounded to 3 dp is 130.316

 

Try this....

 

Round(130.3155, 0.001)

 

It gives 130.315 

 

Why? and how can I get round to behave as expected?

6 REPLIES 6
estherb47
15 - Aurora
15 - Aurora
Will work on troubleshooting the Round function later, but you can try a
fixed decimal data type with 3 decimal places.

I'd do this in a select tool. set it to 9.3, so you have room for larger
numbers before the decimal point.

Let me know if that helps.

Cheers!
Esther

--
Jonathan-Sherman
15 - Aurora
15 - Aurora

Hi @craigja,

 

It looks as though the round function is rounding it down. I'll take a look at why in a little bit.

 

However you could add 0.001 to your value to get around the issue: Round([Value]+0.001, 0.001)

 

image.png

 

If this solves your issue please mark the answer as correct, if not let me know!

 

Jonathan

Maskell_Rascal
13 - Pulsar

Hey @craigja 

 

So this is a really weird issue that I've seen other people discuss on the message boards. The workaround that I use is to separate the number into a whole number and decimal, round the decimal separately, and then add the two values back together. 

 

The formula to do it looks like the below. I've also attached a sample workflow for you. 

 

ToNumber(REGEX_Replace(ToString([Field1]), "\.(.*)",""))+Round(ToNumber("."+REGEX_Replace(ToString([Field1]), "(.*)\.","")),0.001)

 

Maskell_Rascal_0-1588785897096.png

Let me know if this works for you.

 

Thanks!

Phil

Paddi
8 - Asteroid

Hi @Maskell_Rascal , really appreciate your workflow updated. It seems the solution does not work if there are more than 5 digits, can you help me with it? Thank you.

 

ToNumber(REGEX_Replace(ToString([Field1]), "\.(.*)",""))+Round(ToNumber("."+REGEX_Replace(ToString([Field1]), "(.*)\.","")),0.00001)

 

gautiergodard
13 - Pulsar

Hey @Paddi 

I would try this formula:

Round(Round([original], .0001),.001)

Please accept as solution if it answered your question.

 

Hope this helps! 

bertal34
8 - Asteroid

@Paddi 

 

the solution which Maskell_Rascal provided is working for me.  Can you provide an example number for which his solution is not working please?


thanks.

Labels