WeeklyAlteryxTips#28 How to write an IF statement in an easy-to-understand manner


When you think of the Alteryx, you probably think of it as a “Tool”, but functions play a very important role in some tools. There are many tools that you should use functions, such as the Formula tool, the Multi-Row Formula tool, the Multi-Field Formula tool, the Filter tool, the Generete Rows tool, the Action tool, Condition tool, etc.

And also, there are so many functions that you can use. Actually, there are 13 categories and 210 functions. To understand the tool is very important, and to understand the functions is very important, too.

Now let’s think of the condition expression. The condition expressions are in the “Conditional” category.

There are three functions, which are “IF~THEN~ELSEIF~ELSE~ENDIF”, “IIF” and “SWITCH”. Generally, IF statements are often used because it is the most flexible. On this post, let’s see the IF statement.

IF statement

IF statement is as follows.


“c” is condition that is the formula for the judgement. For example, It is [Field1]=”a”. This means that when the field “Field1″‘s value is “a”, it becomes true and returns “t”, otherwise it becomes false and goes to the next condition “c2”. If none of the conditional expressions are true, returns “f”. If you have only one condition, you can omit the “ELSEIF c2 THEN t2” part.

Complex conditions

When you have complex conditions, you may write the complex condition on “c” part. But if you write complex condition, it will not only understand for other people,but maybe you won’t understand in a year’s time either.

For example, I prepared the sample below.

Here, suppose you need to change the output value depending on the Flag field value. Specifically, the details are as follows.

  • Flag:True
    • Value is 0.5 or more : Set to 1
    • Value is less than 0.5 : Set to 2
  • Flag:False
    • Value is less than 0.6 : Set to 1
    • Value is 0.6 or more : Set to 2

In this case, the expressions are as follows.

IF [Flag] AND [value]>=0.5 THEN 1
ELSEIF [Flag] AND [value]<0.5 THEN 2
ELSEIF ![Flag] AND [value]<0.6 THEN 1
ELSEIF ![Flag] AND [value]>=0.6 THEN 2
ELSE Null()

It’s not so complex condition, but the expressions are a little complex. But you can nest the IF statement, so you can also make the expressions as follows.

IF [Flag] THEN
 IF [value]>=0.5 THEN 1
 IF [value]<0.6 THEN 1

In this case, the IF statement structure is quite simple and easy to understand. This structure means that at the first classify the cases using the “Flag” field, and then classify the conditions using the value of the “value” field. The notation is simple by processing multiple conditions step by step. And also the words are less than the previous expression. Furthermore, the performance is better than the previous expression.


Since the Alteryx Designer is a no-code tool with good visibility, it is desirable to create workflows that are as easy to understand as possible. By writing an IF statement within an IF statement, you can clearly state the condition, so please make use of it.

Sample Workflow Download

Contents of the next blog

I would like to post the article that is tips of functions.


Copied title and URL