Alteryx Designer Desktop Discussions

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

Calculation incorrect output

zoesaleh
5 - Atom

Hello, can anyone explain to me why this is calculating incorrectly:

zoesaleh_0-1611919371279.png


If I multiply everything by 10 it calculates correctly:

zoesaleh_1-1611919418046.png

 

 

4 REPLIES 4
AngelosPachis
16 - Nebula

Hi @zoesaleh ,

 

Not 100% sure why your statement doesn't work, but it's probably how Alteryx interprets the statement. I will have a look at that and try to understand why it happens, but as an alternative you can try the following expression

 

 

IF [Value]>=10 then 5
ELSEIF [Value]>=9 THEN 4
ELSEIF [Value]>=8 THEN 3
ELSEIF [Value]>=7 THEN 2
ELSE 1
ENDIF

 

zoesaleh
5 - Atom

I tried changing my expression to the format you suggested but I still get an incorrect result. My work around works by multiplying by 10 so it is not a decimal so I am using that for now, but I now have no trust in Alteryx to calculate correctly. It was only by chance where some spot checking was being done that this was spotted. If you do find an answer that would be great to know under what circumstances this happens so I can make sure I factor it in to my workflows.

zoesaleh_0-1611921510116.png

 

Jonathan-Sherman
15 - Aurora
15 - Aurora

Hi @zoesaleh,

 

You'll want to round your numbers to 0.01 before doing the check. It can be caused by how computers store numbers (binary system) meaning numbers don't get stored as the exact number (sometimes slightly less). Therefore the value of 0.7 could be 0.6999 for example which wouldn't meet the criteria for 2.

 

IF Round([Value],.01)>=1 then 5
ELSEIF Round([Value],.01)>=.9 THEN 4
ELSEIF Round([Value],.01)>=.8 THEN 3
ELSEIF Round([Value],.01)>=.7 THEN 2
ELSE 1
ENDIF

 

Jonathan-Sherman_0-1611923797585.png

 

Hopefully this solves your issue! I've attached my workflow for you to download if needed.

 

Kind regards,

Jonathan

 

zoesaleh
5 - Atom

Thank you @Jonathan-Sherman that is a really great solution. I will be rounding my numbers from now on, I was totally unaware that computers do this!

Labels