Tutorial Gateway

  • C
  • C#
  • Python
  • SQL
  • Java
  • JS
  • BI Tools
    • Informatica
    • Talend
    • Tableau
    • Power BI
    • SSIS
    • SSRS
    • SSAS
    • MDX
    • R Tutorial
    • Alteryx
    • QlikView
  • More
    • C Programs
    • C++ Programs
    • Go Programs
    • Python Programs
    • Java Programs
  • MySQL

Tableau Logical Functions

Tableau provides various Logical Functions to perform logical operations on our data. They are Tableau AND, NOT, OR, IF, ELSEIF, IF Else, CASE, ISNULL, IFNULL, ZN, IIF, etc. In this article, we will show you how to use Tableau Logical Functions with examples.

To demonstrate these Tableau Logical Functions, we are going to use the data present in the Global Super Store Excel Worksheet. So, Please refer to Connecting to Excel Files in Tableau article to understand the connection settings.

Tableau Logical Functions 1

Tableau Logical Functions

The following examples will show you the list of Logical Functions in Tableau

Tableau AND Function

The Tableau AND function is used to check multiple expressions. The syntax of the Tableau AND Function is as shown below:

Expression_1 AND Expression_2

As you see from the above syntax, Tableau AND function accept two arguments. If both the conditions are True, it returns True. Otherwise, it returns False.

To demonstrate these logical functions in Tableau, we have to use Calculated Fields. To create a calculated field, please navigate to Analysis Tab and select the Create Calculated Field… option

Tableau Logical Functions 2

Once you click on the Create Calculated Field… option, following window will be opened. Here, we renamed the default calculation name as AND Function.

It will check whether the Profit is greater than 0, and Quantity is greater than 25000. If both these conditions are true, the Tableau logical AND function will return Good; otherwise, it will return Bad

IF(SUM([Profit]) > 0 AND SUM(Quantity) > 25000) THEN 'Good'
ELSE 'Bad'
END
Tableau AND function 3

Let me add this AND function calculated field to the table (by dragging a field to Rows Shelf). Please refer Create Table Report article to understand the process of creating a table

Tableau AND function 4

Tableau OR Function

The Tableau OR function is like either or statement in English. If both the conditions are False, Tableau or will return False; otherwise, it returns True. The syntax of this Tableau OR Function is:

Expression_1 OR Expression_2

The below statement will return Good if either of these two statements is True

IF(SUM([Profit]) > 0 OR SUM(Quantity) > 300000) THEN 'Good'
ELSE 'Bad'
END
Tableau OR function 5

Let me add this field to the Rows shelf

Tableau OR function 6

Tableau IIF Function

The Tableau IIF function is the simple version of the If Else Function. If both the condition is True, then it will return First Statement otherwise, the second statement. The syntax of this Tableau IIF Function is:

IIF(Expression, True_statement, False_Statement)

The following Tableau IIF function returns Profit if the condition is True. Otherwise, Loss will return.

IIF(SUM([Profit]) > 0, 'Profit', 'Loss')
Tableau IIF Function 7

Now you can see the result of the Table IIF function

Tableau IIF Function 8

Tableau NOT Function

The Tableau NOT function return the exact opposite. I mean, True will become false and vice versa. The syntax of this Tableau NOT Function is:

NOT(Expression)

The below Tableau Not statement will return Loss if the condition is True. Otherwise, Profit will return.

IF(NOT SUM([Profit]) > 0) THEN 'Profit' 
   ELSE 'Loss'
END
Tableau NOT function 9

You can see the NOT function result by yourself

Tableau NOT function 10

Tableau ISNULL Function

To demonstrate this Tableau ISNULL function, we will use the below shown table.

Tableau Logical Functions 11

Tableau ISNULL function will check whether it is NULL or Not. If it is NULL, then it returns TRUE; otherwise, False will return.

The syntax of the Tableau ISNULL Function is:

ISNULL(Expression)

The following statement will check nulls in Service Grade 2 column.

ISNULL([Service Grader 2])
Tableau ISNULL function 12

As you can see, this Tableau ISNULL function returned True for the products under Blue Color.

Tableau ISNULL function 13

Tableau ZN Function

Tableau ZN function will return the original values of Not Null values, and 0 for Null values. In simple English, ZN in Tableau is used to replace the NULL values with 0.

The syntax of the Tableau ZN Function is:

ZN(Expression)

The below Tableau logical function statement will replace NULL with 0.

ZN([Service Grader 2])
Tableau ZN function 15

From the below screenshot, you can see the result of a Tableau ZN function.

Tableau ZN function 16

Tableau IFNULL Function

Tableau IFNULL function is used to replace the NULL values with your own. The syntax of the Tableau IFNULL Function is:

IFNULL(Expression, Value)

The following Tableau ifnull statement will replace NULLs with 10.

IFNULL([Service Grader 2], 10)
Tableau IFNULL function 14

Let us see the result of the Tableau IFNULL

Tableau IFNULL function 18

Filed Under: Tableau

  • Download and Install Tableau
  • Tableau Start Page
  • Tableau Show Me
  • Connect to MS Analysis Services
  • Connecting Tableau to SQL
  • Tableau Connect to Text File
  • Tableau Connect to Excel File
  • Hierarchies in Tableau
  • Tableau Bins
  • Tableau Parameters
  • Combined Tableau Sets
  • Tableau Set
  • How to Edit Tableau Group
  • Tableau Group
  • Tableau Grouping
  • Tableau First Report
  • Data Labels in Tableau Reports
  • Format Tableau Chart Title
  • Create Folders in Tableau
  • Tableau Sort
  • Add Totals in Tableau
  • How to Join Data in Tableau
  • Tableau Data Blending
  • Tableau Table Report
  • Tableau Crosstab Report
  • Tableau Annotations
  • Tableau Charts
  • Tableau Area Chart
  • Tableau Bar chart
  • Tableau Box Plot
  • Tableau Bubble Chart
  • Tableau Bullet Graph
  • Tableau Bump Chart
  • Tableau Circle Views
  • Tableau Dual Combination Chart
  • Tableau Dual Lines Chart
  • Tableau Funnel Chart
  • Tableau Traditional Funnel Chart
  • Tableau Gantt Chart
  • Tableau Grouped Bar Chart
  • Tableau Heat Map
  • Tableau Highlight Table
  • Tableau Histogram
  • Tableau Cumulative Histogram
  • Tableau Line Chart
  • Tableau Lollipop Chart
  • Tableau Pareto Chart
  • Tableau Pie Chart
  • Tableau Scatter Plot
  • Tableau Stacked Bar Chart
  • Tableau Text Label
  • Tableau Treemap
  • Tableau Word Cloud
  • Tableau Waterfall Chart
  • Tableau Individual Axis
  • Tableau Dual Axis
  • Tableau Blended Axis
  • Tableau Add Reference Lines
  • Tableau Add Reference Bands
  • Add Reference Distributions
  • Tableau Maps
  • How to Create a Map in Tableau
  • Use Google Maps in Tableau
  • Mapbox Maps as a Background
  • WMS Server Map as Background
  • Create a Tableau Dashboard
  • Format Dashboard Layout
  • Create Dashboard Device Prev
  • Tableau Dashboard Objects
  • Create a Tableau Story
  • Tableau Filters
  • Tableau Filters on Dimensions
  • Tableau Filters on Measures
  • Tableau Extract Filters
  • Tableau Dashboard Filters
  • Tableau Data Source Filters
  • Tableau Slicing Filters
  • Tableau Quick Filters
  • Tableau Context Filters
  • Tableau Top Filters
  • Tableau Table Calculations
  • Tableau Calculated Fields
  • Tableau Running Total
  • Tableau Rank Calculation Basic
  • Tableau Rank advanced calculate
  • Tableau Aggregate Functions
  • Tableau Conversion Functions
  • Tableau Case Function
  • Tableau Date Functions
  • Tableau If Function
  • Tableau Logical Functions
  • Tableau Math Functions
  • Tableau String Functions
  • Tableau Table Functions

Copyright © 2021· All Rights Reserved by Suresh.
About | Contact | Privacy Policy