Logical Functions... Makes sense right?

When analysing a dataset, you often need insights that aren’t readily available in the dataset but can be derived using the existing fields. This is where calculations and calculated fields in Tableau become incredibly useful. Calculated fields are useful as they can help manipulate the data with unlimited possibilities, allowing for you to enhance the raw data to derive new insights and customize the visual experience for the end user.

Now part of creating a calculation in Tableau is writing in a ‘function’, which gives Tableau instructions on how to process the data within that calculation. Tableau provides a wide range of functions to support this, organising them into 9 main folders: Number, String, Date, Type Conversion, Logical, Aggregate, User, Table Calculation, and Spatial. Each of these categories serves a specific purpose, allowing users to customize their analyses based on their needs. In this blog however, we will be focusing specifically on Logical Functions.

A screenshot of a computer

AI-generated content may be incorrect.

 


 

So what are Logical Functions?

Logical functions in tableau are used to create conditional expressions to identify if that condition has ben met or not. Whilst this is essentially Boolean logic (true or false), many logical functions will give you the option to choose what value to return if that condition has been met (e.g. if a sale is above 500, then label as “High”, else label as “Low”).

Logical functions are useful as they allow users to apply decision making logic within calculated fields, allowing for dynamic data categorisation, filtering and transformations of the data (e.g. using the logic function above, we can now categorise customer as "High" or "Low" based on the sales logic).

A screenshot of a graph

AI-generated content may be incorrect.

 


 

Here are a few that you may come across and use on a regular basis:

 

IF – Test a series of expressions and returns <then> if test is true

    ● and -> performing the logical function based on another expression

    ● then -> return <then> if above expression is true

    ● else -> returns <else> if above expression is false

    ● elseif -> test a new expression if the first expression is false

    ● end -> ending the logical expression

 

IIF – Test a expression and returns <then> if true and <else> if false (and <unknown> if null)

A screenshot of a computer

AI-generated content may be incorrect.

 

CASE – Evaluates the expression, when <value1> is encountered returns <then1> otherwise <else2>

    ● when -> returns <then> when condition <value> is met

    ● then -> return <then1> if <value1> is encountered

    ● else -> returns <else2> if none of the conditions are met

    ● end -> ending the logical expression

A screenshot of a computer

AI-generated content may be incorrect.

 

IFNULL – Returns <expression2> if null, else returns <expression1>

A screenshot of a computer

AI-generated content may be incorrect.

 

ZN – Returns 0 if <expression> is null, else returns back <expression>

A screenshot of a computer

AI-generated content may be incorrect.

 

Thank you for reading! 😊

Victor

Author:
Victor Yuan
Powered by The Information Lab
1st Floor, 25 Watling Street, London, EC4M 9BR
Subscribe
to our Newsletter
Get the lastest news about The Data School and application tips
Subscribe now
© 2025 The Information Lab