10-20-2021 12:43 PM
The syntax of an IF THEN statement in the Expression Editor is incorrect.
Verify that the syntax of the conditional statement is correct. Conditional statements (or conditional functions) perform an action or calculation based on a specified set of states for your data.
IF c THEN t ELSE f ENDIF
Returns t if the condition c is true, else returns f. For example, if I donate to NPR, I will receive a tote bag, otherwise I will not receive the tote bag.
IF c THEN t ELSEIF c2 THEN t2 ELSE f ENDIF
Returns t if the first condition c is true, else returns t2 if the second condition c2 is true, else returns f. If I donate to NPR and my gift is over $100, then I will receive a clock radio, otherwise I will not receive the clock radio.
IIF(bool, x, y)
Returns x if bool is true, else returns y.
For more information on conditional functions , see Alteryx Help.
In tools with an updated UI, like Filter and Formula, a small red squiggle will underline the position of the character where the error starts. The error message itself includes the character position (remember that Alteryx is zero-based, so start counting at zero).
Note that each part of the syntax is a different color, or in italics. The functions are gold, variables are fuchsia, operators are magenta, the string values are blue-green, numeric values and unrecognized text are black. This can help with troubleshooting the incorrect expression.
In tools like Multi-Row Formula, Multi-Field Formula, Dynamic Rename and Dynamic Select, clicking the red Go at the bottom right of the tool configuration will put your cursor at the character where the error starts. In the below image, since the expression is missing an ENDIF, the cursor is at the end of the statement where the ENDIF belongs.
If [Fiscal Month] = 1 THEN 'Oct'
ELSEIF [Fiscal Month] = 2 THEN 'Nov'
ELSEIF [Fiscal Month] =3 THEN 'Dec'
ELSEIF [Fiscal Year] = 4 THEN 'Jan'
ELSEIF [Fiscal Year] = 5 THEN 'Feb'
ELSEIF [Fiscal Year] = 6 THEN 'Mar'
ELSEIF [Fiscal Year] = 7 THEN 'Apr'
ELSEIF [Fiscal Year] = 8 THEN 'May'
ELSEIF [Fiscal Year] = 9 THEN 'Jun'
ELSEIF [Fiscal Year] = 10 THEN 'Jul'
ELSEIF [Fiscal Year] = 11 THEN 'Aug'
ELSEIF [Fiscal Year] = 12 THEN 'Sep'
ENDIF
This is giving me an error message. What is wrong in this forumula? I am very new to Alteryx
You should end with an ELSE and not an ELSEIF at the last part. Like so (In bold):
IF c THEN t ELSEIF c2 THEN t2 ELSE f ENDIF
Hi,
having the same issue