When I was working on a Tableau report, I needed to highlight customers who spent more than $10,000 in purchases. I tried using filters, but it was not possible to create custom categories and categorize the customers in specific groups using filters.
As a solution for this, I used the IF statement in Tableau. With this, I was able to create a new field that marked such customers as “Premium” and others as “Regular.” This made it easier to use the calculated field in charts, filters, and dashboards.
In this tutorial, I’ll explain what the IF statement is in Tableau and how we can use it with the help of examples.
IF Statement in Tableau
In Tableau, an IF statement is a logical function that creates a calculated field to perform conditional logic on the data, returning one value if a condition is TRUE and another if it’s FALSE.
The syntax of using the IF statement in the Tableau formula is as follows.
IF [condition] THEN [value if true] ELSE [value if false] END
Using this, if-then logic, the formula will return one value if the condition is True, else it will return another value.
Use an IF Statement in Tableau
In the examples below, I will show how we can create a formula using the IF statement for simple logic and by using the IF statement with multiple conditionals for complex logic.
- Example-1: Classify sales as high or low using an if statement
- Example-2: Use multiple If conditions with Elseif
- Example-3: Use Tableau aggregation functions with IF
- Example-4: Nested IF statements in Tableau
- Example-5: Use conditional statements with IIF statements
Example-1: Classify Sales as High or Low Using an IF Statement
In this example, we will divide sales into two groups: High Sales above 5000 and Low Sales below or equal to 5000.
- To create a calculated field, click on the Analysis tab and select Create Calculated Field.

- Enter the formula below in the calculated field to divide the sales into two categories, “High Sales” and “Low Sales“.
IF [Sales] > 2000 THEN "High Sales"
ELSE "Low Sales"
END
In this example, I have labelled the calculated field as Sales Group.
- Now, add Sales to Rows and Customer Name to Columns. Here, you can also filter out the customer records.
