Alteryx Designer Desktop Discussions

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

Imbedded IF THEN Statement

KmbrlyPC
8 - Asteroid

I can't seem to figure out what is wrong with this embedded if then statement and what seems to be wrong near the end.

 

IfThen.PNG

6 REPLIES 6
JagdeeshN
12 - Quasar
12 - Quasar

@KmbrlyPC 

 

The error  is because you are trying to apply Integer/Number operations on a string.  For eg [Days Until Due]<"8"  applies a integer operation(<) on a string("8").

 

If you change the datatype of the fields, the below formula should work.

 

jagdeeshn_0-1613067900552.png

Please find attached a sample workflow.

 

Do let me know if this helps.

 

Best,

Jagdeesh

apathetichell
19 - Altair

I think with ALTERYX the THEN/IF combo doesn't really work. Use something like this instead:

IF THEN ELSEIF THEN ELSEIF THEN ELSEIF THEN ELSE ENDIF

 

I do not think you can place an ENDIF in a statement prior to close either - so I'd try:

if [CC]=0 then "none completed" elseif [days until due]< 8 then "due within one week" elseif  [days until due]>8 then "more then 1 week" else "past due" endif.

 

Keep in mind that you have string comparisons set up for numeric operators so in a string system your formula might not produce an error but it would create a mistake - ie. the string of "11" is less than "8" so it would produce "Due Within 1 Week," instead of "Past Due" you can intermingle numeric/string operators by using TONUMBER/TOSTRING.

 

Hope that helps!

KmbrlyPC
8 - Asteroid

I took out the Completed Count and simplified the formula, but it is now giving me an error or a malformed statement. The "Days Due" field is a number.

 

IfThen.PNG

DellChristy
6 - Meteoroid

What is the data type of [Past Due Status]?  If it's not a string, that's your problem.  The result if each part of the IF statement needs to be the same data type.

apathetichell
19 - Altair

try ELSEIF as one word too.. If that doesn't work - I'm sure someone here can help if you include a sample of your data.

KmbrlyPC
8 - Asteroid

It works now! THANK YOU!

Labels