Let’s talk Alteryx Copilot. Join the live AMA event to connect with the Alteryx team, ask questions, and hear how others are exploring what Copilot can do. Have Copilot questions? Ask here!
Start Free Trial

Alteryx Designer Desktop Discussions

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

Malformed IF statement

mupad2008
6 - Meteoroid

Hi All,

 

Am trying to update Field1 (string) based on multiple if and/or criteria on Field1 to Field5 (some string, some numeric), getting a "malformed if statement" error.

Tried looking up suggestions on previous help topics, still not able to get it resolved.

I have ensured that data type of the fields are correct, f1, f5 are strings, f2, f3, f5 are double

Below is the syntax am using;

IF                            [FIELD1] == ‘ABC’ AND [FIELD5] IN ("X”,”Y”,”Z")                 THEN  "ALPHA"

ELSE IF                  [FIELD1] == "ABC" AND [FIELD2] IN (0,1)                           THEN  "BETA"

ELSE IF                  [FIELD1] == "DEF" AND [FIELD3] = 0 AND [FIELD4] = 0    THEN  "CHARLIE" 

ELSE IF                  [FIELD1] == "DEF" AND [FIELD3] != 0 OR [FIELD4] != 0     THEN = "DELTA"

ELSE                      [FIELD1]

ENDIF

 

Note* Am updating the same field that am comparing in first if condition i.e. if f1  == "abc" and f2 in ("x","y","z") the f1 = "alpha".

 

Thanks!

3 REPLIES 3
Kenda
16 - Nebula
16 - Nebula

Hey @mupad2008

 

I was able to modify your formula a bit and get the desired output.

 

IF                       [FIELD1] = "ABC" AND [FIELD5] IN ("X","Y","Z")                 THEN  "ALPHA"

ELSEIF                  [FIELD1] = "ABC" AND [FIELD2] in(0,1)                           THEN  "BETA"

ELSEIF                  [FIELD1] = "DEF" AND [FIELD3] = 0 AND [FIELD4] = 0    THEN  "CHARLIE" 

ELSEIF                  [FIELD1] = "DEF" AND ([FIELD3] != 0 OR [FIELD4] != 0)     THEN  "DELTA"

ELSE                      [FIELD1]

ENDIF

The main thing is that, in Alteryx, the ELSEIF will go together with no space. I also changed a couple of the quotes and added parenthesis to the final statement as well to get it to work.

 

Hope this helps!

mupad2008
6 - Meteoroid

Bingo! 

 

It indeed was 'ELSE IF' I used as against 'ELSEIF' that is needed.

 

Thanks BarnesK!!!

RossLewis76
5 - Atom

Perfect! The Else If/ElseIf was my downfall as well.

Labels
Top Solution Authors