Alteryx Designer Desktop Discussions

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

How to use multiple IF statements with multiple AND statements

HannahReed1145
6 - Meteoroid

If someone could help me with designing a multiple if statement with 3 conditions, I would appreciate your help!! 

 

I have two categories that I would like to draw from: age and gender. 

 

I would like to say, if the age is from 10 to 13 and is a female, then "F10-13". I have about 19 different categories like that I would like to establish and for both genders. 

 

Currently, my formula looks like this: 

IF [age] >= 10 OR [age] <= 13 AND [gender] = "F"
THEN "F10-13"

ELSEIF [age] >10 and [age] <13 and [gender] = "M"
THEN "M10-13"
ELSEIF [age] >14 and [age] <17 and [gender] = "F"
THEN "F14-17"

ELSEIF [age] >14 and [age] <17 and [gender] = "M"
THEN "M14-17"

ELSEIF [age] >18 and [age] <21 and [gender] = "F"
THEN "F18-21"

ELSEIF [age] >18 and [age] <21 and [gender] = "M"
THEN "M18-21"

ELSEIF [age] >22 and [age] <25 and [gender] = "F"
THEN "F22-25"

ELSEIF [age] >22 and [age] <25 and [gender] = "M"
THEN "M22-25"

[etc.]

ELSE "NULL"
ENDIF

 

However, when I type this in, it states it as "invalid" 

 

Please help! Thank you!

12 REPLIES 12
Vikas27
7 - Meteor

I would like to design a code if my Book is X or Y than POD should be TRS else NULL

 

I'm writing code as IF [Book] = "X" OR [Book] = "Y" THEN [POD] = "TRS" ELSE [POD] = "NULL" ENDIF

 

But its not working. Can someone please guide? 

dYoast
11 - Bolide

@Vikas27 , It is better to start a new post.  More people will look at it versus a Solved post.

 

Your formula should be:  IF [Book] = "X" OR [Book] = "y" THEN "TRS" ELSE Null ENDIF

 

dYoast_0-1648674101734.png

 

Vikas27
7 - Meteor

Thanks, this code worked but what happened is i've tons of books alongwith let's say X and Y it has impacted all other books. I want the code to be designed that it impact only these 2 books. 

 

 IF [Book] = "X" OR [Book] = "y" THEN "TRS" ELSE Null ENDIF

Labels