Alteryx Designer Desktop Knowledge Base

Definitive answers from Designer Desktop experts.

Error: Parse Error at char(n): Malformed If Statement

CristonS
Alteryx Alumni (Retired)
Created
 

Environment Details

 
  • Alteryx Designer
    • All Versions
  • Filter
  • Formula
  • Generate Rows
  • Multi-Field Formula


Cause


The syntax of an IF THEN statement in the Expression Editor is incorrect. 

 


 

Resolution


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). 



image.png

image.png
 

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.



image.png

Comments
mkierepka
6 - Meteoroid

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

 

mkierepka_0-1660160871350.png

 

maamek
7 - Meteor

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

superzebra3000
5 - Atom

Hi,

 

having the same issue 

superzebra3000_0-1678198708298.png