Hello,
I am new to Alteryx and am trying to build a multi-conditional ELSEIF statement. It reads as follows:
IF [Age] <= "30" THEN "0-30"
ELSEIF [Age] <= "60" THEN "30-60"
ELSEIF [Age] <= "90" THEN "60-90"
ELSE [Age]="90+"
ENDIF
When I try to type the "ENDIF" if removes the color and reads an error message. The [Age] column is currently a Double format (previously created in workflow using formula tool: (DateTimeDiff([Cash_Receipt_Date],[Sales_Order_Date],"days") and the new column I am trying to create is a V_Wstring format. I am not sure what I am doing wrong! Thank you.
Solved! Go to Solution.
doubles are measured against numbers so:
[age]<=30 if [age] is a double. You don't need the quotes for the comparison. You will need the quotes for what you are adding to the new string.
Also - your last clause attempts to assign a value to [age] instead of what I believe is the new column you are trying to create. Since you are using vwstring you cannot put it back in [age] and change [age] to a vwstring in your formula tool.
so change the comparison to not include quotes, turn this into a new column, and change the last clause to assign "90+" to your new column - not to [age]
<=> only apply to numeric data, so
try to remove the double quotation as below
IF [Age] <= 30 THEN "0-30"
ELSEIF [Age] <= 60 and [Age] > 30 THEN "30-60"
ELSEIF [Age] > 60 and [Age] <= 90 THEN "60-90"
ELSE "90+"
ENDIF
Thank you so much!
Glad to help and thank you for the accept mark. 😁
Figured it out.