Hello, can anyone explain to me why this is calculating incorrectly:
If I multiply everything by 10 it calculates correctly:
Solved! Go to Solution.
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
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.
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
Hopefully this solves your issue! I've attached my workflow for you to download if needed.
Kind regards,
Jonathan
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!