Free Trial

Alteryx Designer Desktop Discussions

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

Multiple IF Statements Along with "OR"

BrandonS4
8 - Asteroid

I need to have multiple IF statements along with "OR".  I am not getting the results I wanted.  Here is what I have:

 

State

Western NC

Eastern NC

Central NC

West FL

South FL

 

I want to use to say "IF [State] = "Western NC" OR "Eastern NC" OR "Central NC" 

                                 THEN "NC"

                                 ELSEIF [State] = "West FL" OR "South FL"

                                 THEN "FL"

                                 ELSE [State]

                                 END IF

 

I am only getting the first value of each IF statement.  Can anyone help?

 

Thanks!

6 REPLIES 6
Jonathan-Sherman
15 - Aurora
15 - Aurora

Hi @BrandonS4,

 

You're close, just needs a couple of tweaks.

 

IF ([State] = "Western NC" OR [State] = "Eastern NC" OR [State] = "Central NC")
THEN "NC"
ELSEIF ([State] = "West FL" OR [State] = "South FL")
THEN "FL"
ELSE [State]
ENDIF

 

If this solves your issue please mark the answer as correct, if not let me know!

 

Regards,

Jonathan

Jonathan-Sherman
15 - Aurora
15 - Aurora

Hi @BrandonS4,

 

But i would also prefer to clean the statement up a little and use the IN() function rather than repeating the column name each time:

 

IF [State] IN("Western NC","Eastern NC","Central NC")
THEN "NC"
ELSEIF [State] IN("West FL","South FL")
THEN "FL"
ELSE [State]
ENDIF

 

If this solves your issue please mark the answer as correct, if not let me know!

Regards,

Jonathan

BrandonS4
8 - Asteroid

This is what I was looking for.  Thank you for the quick reply!

BrandonS4
8 - Asteroid

One other question.  I currently have this report outputting to 5 sheets...Western NC, Eastern NC, Central NC, West FL and South FL.  How can I add a sheet for NC and FL?

AbhilashR
15 - Aurora
15 - Aurora

Hi @BrandonS4, could you provide us a sample of your data for us to look at? It sounds like you need to summarize your data at State level, in addition to Region. You can write a formula (name it State) and summarize your data at state level, and output it the way you output your regions. 

BrandonS4
8 - Asteroid

I was able to figure this out.  I just created two different file names in two different formula tools then joined them and it worked.

Labels
Top Solution Authors