Tableau Tutorials

# Logical Functions in Tableau

We will study logical functions and how Tableau uses them in this article. For now, consider the following two terms:

• Tableau: For the purpose of visualising data and obtaining a definitive opinion based on data analysis, data analysts, scientists, statisticians, and other professionals can utilise this incredibly potent data visualisation application. Tableau is well-known for its ability to quickly process data and generate the necessary data visualisation output.
• Logical Function: To carry out logical operations on our data, Tableau offers a number of Logical Functions. Tableau AND, NOT, OR, IF, ELSEIF, IF Else, CASE, ISNULL, IFNULL, ZN, IIF, and so on are examples of them.

Let’s go over each logical function with an example one by one. The dataset utilised in the examples provided is Dataset. Check out the online Tableau course to learn more.

AND Function: To view several expressions, use the AND function. The AND Function’s syntax is as follows:

## Expression_1 AND Expression_2

It returns True if both of the conditions are met. If not, False is returned.

• We must utilise Calculated Fields in Tableau to illustrate this logical function.
• Please select the Create Calculated Field… option from the Analysis Tab after navigating there to create a calculated field.
• In the newly created field, apply the expression.

OR Function: Tableau’s OR function is comparable to an English either-or expression. Tableau returns False if both conditions are false; it returns True otherwise. This Tableau OR Function has the following syntax:

## Expression_1 OR Expression_2

• We must utilise Calculated Fields in Tableau to illustrate this logical function.
• Please select the Create Calculated Field… option from the Analysis Tab after navigating there to create a calculated field.
• In the newly created field, apply the expression.

IIF Function: The If Else Function in Tableau is simplified to become the IIF function. It will return the first statement if both conditions are true; else, it will return the second statement. This Tableau IF Function has the following syntax:

## IIF(Expression, True_statement, False_Statement)

• We must utilise Calculated Fields in Tableau to illustrate this logical function.
• Please select the Create Calculated Field… option from the Analysis Tab after navigating there to create a calculated field.
• In the newly created field, apply the expression.

NOT Function: The exact opposite is returned by the Tableau NOT function. True will turn into false, and vice versa. This Tableau NOT Function has the following syntax:

## NOT(Expression)

• We must utilise Calculated Fields in Tableau to illustrate this logical function.
• Please select the Create Calculated Field… option from the Analysis Tab after navigating there to create a calculated field.
• In the newly created field, apply the expression.

ISNULL Function: Tableau’s ISNULL function will determine if a given value is NULL or not. It returns TRUE if it’s NULL; else, False is returned. The Tableau ISNULL Function has the following syntax:

## ISNULL(Expression)

• We must utilise Calculated Fields in Tableau to illustrate this logical function.
• Please select the Create Calculated Field… option from the Analysis Tab after navigating there to create a calculated field.
• In the newly created field, apply the expression.

ZN Function: The Tableau ZN function returns 0 for null values and the first values of not-null values. To put things simply, ZN is used in Tableau to replace NULL values with 0. The Tableau ZN Function has the following syntax:

## ZN(Expression)

• We must utilise Calculated Fields in Tableau to illustrate this logical function.
• Please select the Create Calculated Field… option from the Analysis Tab after navigating there to create a calculated field.
• In the newly created field, apply the expression.

IFNULL Function: You can use Tableau’s IFNULL function to swap out NULL values for your own. The Tableau IFNULL Function has the following syntax:

## IFNULL(Expression, Value)

• We must utilise Calculated Fields in Tableau to illustrate this logical function.
• Please select the Create Calculated Field… option from the Analysis Tab after navigating there to create a calculated field.
• In the newly created field, apply the expression.

IF Function: In Tableau, one of the most important and practical decision-making functions is the IF Function. The function will return the output if it tests the condition and returns the outcome based on the condition.

## IF-END

• In this example, we just use the IF function on a field to generate a new calculated field.
• View the newly computed field.
• Apply to Visualization.
• One of its drawbacks is that if the condition is false, null values are produced.

## IF-ELSE-END

• In this case, we just use the IF-ELSE function in the same field to update the previously calculated field.
• Examine a freshly computed field.
• Apply to Visualization.
• It resolves a flaw that, in the event of a false condition, produces null values.

## IF-ELSEIF-ELSE-END

• In this example, we only use the IF-ELSEIF-ELSE function on a field to generate a new calculated field.
• Examine a freshly computed field.
• Apply to Visualization.

Case Function: In Tableau, Case Function is a subset of Logical functions. When the test expression is true, these functions are used to carry out the logical test and return the necessary value.

• We must utilise Calculated Fields in Tableau to illustrate this logical function.
• Please select the Create Calculated Field… option from the Analysis Tab after navigating there to create a calculated field.
• In the newly created field, apply the expression.