Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

Alteryx Designer Desktop Discussions

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

Writing an If statement with multiple OR

Ravy12
7 - Meteor

I want to write an IF OR Statement for the below table.

 

NameClassSubjectRollDivisionschooltuitionfeesType
RaviY     Y 
Rohit Y YY   
RajeshY  Y Y  
Deepak      Y 
Amit  Y     
Alok     Y  

 

Now, I have to create an Output field name "Type" for which three values should be calculated which is "N", "NNC" and "U" based on the column Class to fees as below:

 

If class = Y or Subject = Y or Roll=Y or Division=Y then "NNC"
Elseif school=Y or tution=Y or fees=Y  then "NC"
Else "U"

I am getting error on above formula....Is there a better way to calculate above formula ?

 

2 REPLIES 2
Kenda
16 - Nebula
16 - Nebula

Hey @Ravy12!

 

Try the below expression in your Formula tool:

iif([Class]="Y" || [Subject]="Y" || [Roll]="Y" || [Division]="Y","NNC",IIF([school]="Y" || [tuition]="Y" || [fees]="Y","NC","U"))
danrh
13 - Pulsar

Three things:

 

1- Add quotes around each "Y" if these are strings fields.  If they are booleans, pull out " = Y" altogether from each.

2- Add "ENDIF" at the end.  Alteryx makes you specifically end your if statement.

3- If this is a straight copy and paste, it looks like tuition needs another "i".  tution -> tuition.

 

So if these are sting fields, try:

If class = 'Y' or Subject = 'Y' or Roll='Y' or Division='Y' then "NNC"
Elseif school='Y' or tuition='Y' or fees='Y' then "NC"
Else "U" endif

 

And if these are booleans

If class or Subject or Roll or Division then "NNC"
Elseif school or tuition or fees then "NC"
Else "U" endif

 

Good luck!

Labels