Open In App

IF Function in Tableau

Last Updated : 10 Sep, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

The IF function in Tableau is a decision-making function that tests a condition and returns a result based on whether the condition is TRUE or FALSE. It is widely used to create calculated fields that categorize or transform data dynamically. It helps apply conditional logic in Tableau like creating custom categories (e.g., High, Medium, Low sales).

Working

  • Tableau evaluates the first condition after IF.
  • If it is TRUE, the specified result is returned.
  • If not, it checks the next condition with ELSEIF.
  • If none match, the ELSE value is returned as a default.

Syntax

IF <Expression1> THEN <Statement1>
ELSEIF <Expression2> THEN <Statement2>
ELSEIF <Expression3> THEN <Statement3>
.....
ELSEIF <ExpressionN> THEN <StatementN>
ELSE <Statement>
END

This function checks the given <expression> and returns the corresponding value as a result.

  • IF: begins the logical test
  • ELSEIF: adds additional conditions
  • ELSE: defines the default output if no condition matches
  • END: closes the function

Example 1: (IF-END)

  • In this example, we simply create a new calculated field by using the IF function on a field.
  • View a new calculated field.
  • Use in Visualization.
  • It has a drawback that creates null values in case of the false condition.

Example 2: (IF-ELSE-END)

  • In this example, we simply edit that previously calculated field by using the IF-ELSE function in the same field.
  • View a new calculated field.
  • Use in Visualization.
  • It overcomes a drawback that creates null values in case of the false condition.

Example 3: (IF-ELSEIF-ELSE-END)

  • In this example, we simply create a new calculated field by using the IF-ELSEIF-ELSE function on a field.
  • View a new calculated field.
  • Use in Visualization.

Article Tags :

Explore