Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.

Alteryx Designer Desktop Discussions

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

Rounding negative numbers that end in 50 not rounding correctly

sonseeahray
8 - Asteroid

I am using the following formula to round my numbers to the nearest 100. It works for all but any negative number ending in 50. 

 

Creating a new field called New Amount: Round([Amount]*[Rate],100).

 

Here is a small sample of both expected and unexpected results.

 

AmountNew AmountShould be
254.24300.00300.00
3757.1733333800.003800.00
294.24300.00300.00
176.96200.00200.00
-5250-5200.00-5300.00
-500.00-100.00
-150-100.00-200.00
-750-700.00-800.00

 

 

4 REPLIES 4
DavidP
17 - Castor
17 - Castor

-5250 will round up to the bigger nearest 100.

 

In this case -5200 is the bigger number and -5300 is the smaller number and the same for all your other negative numbers

sonseeahray
8 - Asteroid

@DavidP Thank you. Should I use an IF statement, one for >=0 and one for <0? And, if so, how would I write the formula?

fmvizcaino
17 - Castor
17 - Castor

Hi @sonseeahray ,

 

You can use the following formula:

if [Amount]>0 then Round([Amount], 100)
else -Round(-[Amount], 100)
endif

 

Best,

Fernando Vizcaino

sonseeahray
8 - Asteroid

@fmvizcaino Thank you. That is it!

Labels