Alteryx Designer Desktop Discussions

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

Formula Help

Riot
8 - Asteroid

So I am trying to create a status variable. It looks like this 

 

IF [Age] > 18 AND [Sex] = 'Female' AND [Parch] > 0 AND [Salutation] != "Miss."
THEN "Mother"
Else
IF [Age] > 18 AND [Sex] = 'Male' AND [Parch] = 0 AND [SibSp] =0
THEN "SingleMan"
Else
IF [Age] >=12 AND [Parch] >0
THEN "Child"
ELSE "Regular"
ENDIF

 

But as you can see, that doesnt seem to work. Any ideas how to make it functionable ?

3 REPLIES 3
MarqueeCrew
20 - Arcturus
20 - Arcturus

IF [Age] > 18 AND [Sex] = 'Female' AND [Parch] > 0 AND [Salutation] != "Miss."
THEN "Mother"
ElseIf
 [Age] > 18 AND [Sex] = 'Male' AND [Parch] = 0 AND [SibSp] =0
THEN "SingleMan"
ElseIf
 [Age] >=12 AND [Parch] >0
THEN "Child"
ELSE "Regular"
ENDIF

Alteryx ACE & Top Community Contributor

Chaos reigns within. Repent, reflect and restart. Order shall return.
Please Subscribe to my youTube channel.
Riot
8 - Asteroid

Helpful As always! Thank you!

michael_treadwell
ACE Emeritus
ACE Emeritus

To add to @MarqueeCrew:

 

When you put a space between ELSE and IF, you are initiating another IF statement: a nested IF.

 

IF [this]

THEN 'that'

ELSE IF [this other thing] THEN 'that other thing' ELSE 'done' ENDIF

ENDIF

 

 

 

ELSEIF just adds another condition to your IF statement.

 

IF [this]

THEN 'that'

ELSEIF [this other thing]

THEN 'that other thing'

ELSE 'nothing'

ENDIF

 

Both of these are syntactically valid but they are used for different reasons.

 

Labels