Tableau IFNULL Function

The Tableau IFNULL is one of the logical functions that will replace the existing NULL values with the user-specified value. The IFNULL function checks whether the column value is NULL; if it is null, it will replace it with a user-specific value. Otherwise, it returns the column value.

This article will show you how to use the IFNULL function with an example. The syntax of the Tableau IFNULL function is as shown below.

IFNULL(Expression, Value)

From the above syntax, the Tableau IFNULL function checks whether the expression is NULL; if true, replace it with Value. Otherwise, print the expression.

For instance, Expression = NULL and Value = 20, and the result is.

IFNULL(NULL, 20) = 20

Similarly, Expression = 100 and Value = 50, and the Tableau result is.

IFNULL(100, 50) = 100

Tableau IFNULL Function Examples

To demonstrate this IFNULL logical function, we will use the Employee table numerical and string columns. First, we must create a calculated Field to write this built-in IFNULL function expression.

To do this, right-click the empty space within the Measures shelf to select the Create Calculated Field .. option. Please refer to the NULL function and for all the built-in functions >> Click Here!.

Employee Table report

In the first example, we will use the Tableau IFNULL function with the Sales and 111 as the first and second arguments. It will check whether there are null values in the Sales column, and if it is true, replace those NULLs with 111.

IFNULL([Sales], 111)
Create a Calculated field to write the Tableau IFNULL Function

Next, let me add that Result calculated field to the table Measure Value shelf. To do so, double-click the Result calculated field. Looking at the output, you can see the original values for non-null values and 111 for the null values.

Add Tableau IFNULL Function calculated field to the table report

Let me Edit the existing Result calculated field by using the down arrow. This time, we use the Dimension column, i.e., Occupation. The below Tableau IFNULL function expression replaces the NULLs in the Occupation column with the HELLO WORLD message or string. You see the changes in the image below as we hit the apply button.

IFNULL([Occupation], "HELLO WORLD")
Tableau IFNULL Function result