Free Trial

Alteryx Designer Desktop Discussions

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

Multi-Condition IF THEN ELSE statement

phil_budden
8 - Asteroid

Hi All,

 

I was wondering if anyone knows of a way to do a multi-condition 'IF THEN ELSE' statement in the formula tool,

 

I want to replace the contents of a string but only if two conditions are met, so for example:

 

Output Field

[FIELD 1]

 

IF [FIELD 2] = "X" and [FIELD 3] = "Y" THEN "Replacement Text" ELSE [FIELD 1] ENDIF

 

Alternitivly is there a better way to acheive this?

 

Thanks in advance...

14 REPLIES 14
Matt_Sinker
7 - Meteor

Hi guys, I'm trying to create an If statement with 3 conditions.

 

But cant get it to work, basically I'm wanting a new column with a Y/N depending on the three previous column rules ("Y", "N", "N" = "Y")

 

i.e. IF [x]="Y" THEN "Y" ELSEIF [x2]="N" THEN "Y" ELSEIF [x3]="N" THEN "Y" ELSE "N" ENDIF

 

Any ideas where I am going wrong?

BenMoss
ACE Emeritus
ACE Emeritus
Hi Matt,

It's not clear exactly what your issue is here? Are you getting an incorrect syntax issue or is your logic statement just not working how you want?

If the latter can you please share a few sample lines and the desired result.

Ben
Matt_Sinker
7 - Meteor

Hi Ben,

 

The error reads: "Parse Error at char(0)L Invalid type in operator ==.(Expression #1)

 

This is the written formula: IF [2 Case EOQ?]="Y" THEN "Y" ELSEIF [Days Cover Filter]="N" THEN "Y" ELSEIF [Case More Than £50?]="N" THEN "Y" ELSE "N" ENDIF

BenMoss
ACE Emeritus
ACE Emeritus

Okay, so this is because your fields are not strings; could you check the datatype of the fields prior to your formula tool? Perhaps they are set to bool? In which case your statement needs to look something like...

 

IF [2 Case EOQ?] THEN "Y" ELSEIF ![Days Cover Filter] THEN "Y" ELSEIF ![Case More Than £50?] THEN "Y" ELSE "N" ENDIF

With bool fields Alteryx will automatically check for a positive class hence [2 Case EOQ?] alone. If I want to check the negative class then I can add an exclamation mark in front.

 

Ben

Matt_Sinker
7 - Meteor

Hi Ben,

 

Thanks for the help, that has worked!!

Labels
Top Solution Authors