Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.

Alteryx Designer Desktop Discussions

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

Stacking IF functions

carterfleming
8 - Asteroid

I'm creating a workflow that will take the place of a sort of cascading series of filters that have to follow a certain hierarchy. In other words, Filter 1 has to be applied before Filter 2 can be applied because some items that may meet the criteria of Filter 2 happen to fall first into the Filter 1 category. For my flow, I have to do this with 20 filters. I haven't thought of a better way to accomplish this than by trying to create some sort of stacked IF statements. See example in attached screenshot. This screenshot is showing what would be the second filter in the sequence. For reference, the "Handling Description" column is what I'm using to give each line item its filter name/category. 

 

 

I realize by the time I'm on the 20th filter, I'll have a lot of these stacked on top of each other. Any easier way to do this? And if not, how do I go about closing IF statements similar to the one shown in the screenshot?

3 REPLIES 3
ChrisTX
16 - Nebula
16 - Nebula

Using only 4 or 5 of your 20 filters, can you provide sample input and expected output?

 

If you can complete the task in Excel, and the most efficient method is one-by-one Filters, then what you have is likely the most efficient method. 

 

For your IF statements, the syntax should contain "IF" only once, at the beginning.  After each AND, don't use another "IF".

IF c THEN t ELSEIF c2 THEN t2 ELSE f ENDIF

 

Here are all of the functions:  https://help.alteryx.com/20221/designer/functions

 

 

 

Chris

Emmanuel_G
13 - Pulsar

Hi @carterfleming ,

 

You can add as many sub-conditions as you want. According to the nomenclature

if Test1 then Result1
elseif Test2 then Result2
elseif Test3 then Result3

.

.

.
else value_by_default endif

 

Note that before endif in if condition, you must have an else in case none of the previous conditions are met.


This is the main concern of your Formula tool.

carterfleming
8 - Asteroid

Thanks!

Labels