Conditional Logic
in Tableau Calculations
Master IF, ELSEIF, and CASE statements to build dynamic, intelligent calculated fields in Tableau.
What Is Conditional Logic?
Conditional logic allows your calculations to make decisions. Instead of applying the same formula to every row of data, you can branch into different outcomes based on whether a condition is true or false.
Why It Matters in Tableau
The Three Conditional Tools
Tableau provides three primary constructs for branching logic in calculated fields:
The IF Statement: Syntax
How IF Evaluates
The CASE Statement: Syntax
IF vs CASE: Key Distinction
| IF / ELSEIF | CASE | |
|---|---|---|
| Evaluates | Boolean expressions | Single expression vs values |
| Condition type | Any: \( > \), \( < \), \( = \), AND, OR | Equality only (\( = \)) |
| Best for | Ranges, complex rules | Discrete categories |
| Readability | Can get verbose | Clean with many values |
| ELSE clause | Optional | Optional |
The IIF Shortcut
IIF is a compact, single-condition function. It takes exactly three arguments: a Boolean test, the value if TRUE, and the value if FALSE. There is no ELSEIF: for multiple branches, use IF instead.
How to Apply Conditional Logic
Example 1: Profit Tier
Classify each order as High, Medium, or Low profit:
Example 2: Region Mapping
Map region abbreviations to full names using CASE:
Example 3: Dynamic Discount
Apply a discount rate that depends on both customer segment and order amount:
Nesting vs Chaining
Common Mistakes
Summary Comparison
| IF / ELSEIF | IIF | CASE | |
|---|---|---|---|
| Branches | Unlimited | 2 (true/false) | Unlimited |
| Condition | Any Boolean | Any Boolean | Equality only |
| Ranges | ✓ Yes | ✓ Yes | ✕ No |
| Readability | Good | Best (short) | Best (many values) |
| Use case | Complex rules | Binary flags | Dimension mapping |
Question 1 of 5
Which statement is TRUE about the CASE construct in Tableau?
Question 2 of 5
Consider the following calculated field:
IF \(\text{[Sales]} > 100\) THEN "Above Average"
ELSEIF \(\text{[Sales]} > 500\) THEN "Top Tier"
ELSE "Below Average"
END
A record with \(\text{Sales} = 750\) would be classified as:
Question 3 of 5
You need to create a calculated field that maps four product categories to custom display names. Which construct is most readable?
Question 4 of 5
What happens when an IF/ELSEIF statement has no ELSE clause and none of the conditions are TRUE?
Question 5 of 5
Which function is best for creating a simple binary flag like "In Stock" vs "Out of Stock"?