Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.

Alteryx Designer Desktop Discussions

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

Multip Row Formula took - Malformed If Statement

collinjd
8 - Asteroid

Hi, I am getting a Malformed IF statement on Multi-Row Formula tool and I can't work out why have tried lots of variations but keep getting errors.

I want to see the same populated in both rows that relate to each other. I am grouping by a specific field (Trade ID) and this record has 2 lines and I want to check that both sides agree and populate whether it is an error (Break) or not.

 

The statement I am using is:

 

 IF [SIDE] = "GTR" AND [Row+1:UTI_ID] = [UTI_ID] then "OK" ELSE "BREAK" ELSEIF [SIDE] = "ARRT" AND [Row-1:UTI_ID] = [UTI_ID] then "OK" ELSE "BREAK" ENDIF

 

It works for one side if I remove everything after the ELSEIF.

 

Thanks

 

 

4 REPLIES 4
BenMoss
ACE Emeritus
ACE Emeritus

Hi!

 

You can't have an else and and elseif in the same non-closed if statement...

 

 IF [SIDE] = "GTR" AND [Row+1:UTI_ID] = [UTI_ID] then "OK" ELSE "BREAK" ELSEIF [SIDE] = "ARRT"

 

You can only have a single 'else' criteria per if statement. i.e. if the count of 'else' exceeds the count of 'if' then your statement has not been formatted correctly.  

I believe you want your statement to be...

IF [SIDE] = "GTR" AND [Row+1:UTI_ID] = [UTI_ID] then "OK"

ELSEIF [SIDE] = "ARRT" AND [Row-1:UTI_ID] = [UTI_ID] then "OK"

ELSE "BREAK" ENDIF

 

Ben

StephenR
Alteryx
Alteryx

You cannot have an ELSE before an ELSEIF.  The proper syntax would be:

 

IF [SIDE] = "GTR" AND [Row+1:UTI_ID] = [UTI_ID] then "OK"  ELSEIF [SIDE] = "ARRT" AND [Row-1:UTI_ID] = [UTI_ID] then "OK" ELSE "BREAK" ENDIF

 

EDIT: @BenMoss 's reply is the same, and better.  Refresh rate is a killer.

 

Regards,
Stephen Ruhl
Principal Customer Support Engineer

ivoller
12 - Quasar

Hi,

 

Can you post sample data and the expected results? The statement is malformed because of the mix of ELSE and ELSEIF and I'm not quite clear on what the tests should be.

 

Iain

 

Edit: Ignore - see previous answers

collinjd
8 - Asteroid

Thank you! this worked :)

Labels