01 / 20

Handling Nulls
in Tableau

Master the art of managing missing values using \(\texttt{IFNULL}\), \(\texttt{ZN}\), and \(\texttt{COALESCE}\) to build reliable, error-free dashboards.

Tableau

What Is a Null Value?

A null represents the absence of any data: it is not zero, not an empty string, and not "false." In Tableau, null values appear when a field has no recorded entry: a missing sales figure, a customer with no phone number, or a dimension that does not apply to a given row.

Product Revenue Discount Region Widget A $1,200 10% East Widget B Null 5% Null Widget C $800 Null West Dashed red outlines mark null cells

Why Nulls Break Dashboards

✕ Broken Calculations
Any arithmetic with a null returns null: \(100 + \texttt{Null} = \texttt{Null}\). One missing cell can cascade through your entire calculated field.
✕ Skewed Averages
\(\texttt{AVG}\) ignores nulls, so your average may represent fewer rows than expected, hiding data quality issues.
✕ Missing Marks
Null dimensions cause blank entries in filters and legends, confusing end users.

Null Propagation Explained

When a null appears in an expression, it "propagates" through the entire calculation. This is because Tableau follows standard database semantics: any operation involving null yields null.

Price: 50 Qty: Null × Result: Null Result: 0
After applying \(\texttt{ZN()}\)

The Three Null-Handling Functions

\(\texttt{IFNULL}\)
Returns the replacement value if the expression is null. Takes exactly 2 arguments.
\(\texttt{ZN}\)
Shortcut: replaces null with zero. Takes exactly 1 argument. Designed for numeric fields.
\(\texttt{COALESCE}\)
Returns the first non-null value from a list. Takes 2 or more arguments, checking left to right.

\(\texttt{IFNULL}\): The Custom Replacement

$$ \begin{aligned} & \color{#64748b} \texttt{// Syntax} \\ & \texttt{IFNULL(expression, replacement\_value)} \\ & \\ & \color{#64748b} \texttt{// Example: Replace null discounts with 0} \\ & \texttt{IFNULL([Discount], 0)} \\ & \\ & \color{#64748b} \texttt{// Example: Replace null regions with text} \\ & \texttt{IFNULL([Region], "Unassigned")} \end{aligned} $$
1
Check the expression. Tableau evaluates the first argument.
2
If it is NOT null: return the original value unchanged.
3
If it IS null: return the second argument as the replacement.

\(\texttt{ZN}\): Zero for Null

$$ \begin{aligned} & \color{#64748b} \texttt{// Syntax} \\ & \texttt{ZN(expression)} \\ & \\ & \color{#64748b} \texttt{// Equivalent to:} \\ & \texttt{IFNULL(expression, 0)} \\ & \\ & \color{#64748b} \texttt{// Example: Safe multiplication} \\ & \texttt{[Price] * ZN([Quantity])} \end{aligned} $$

\(\texttt{COALESCE}\): Cascading Fallback

$$ \begin{aligned} & \color{#64748b} \texttt{// Syntax} \\ & \texttt{COALESCE(expr1, expr2, ..., exprN)} \\ & \\ & \color{#64748b} \texttt{// Example: Try Mobile, then Home, then default} \\ & \texttt{COALESCE([Mobile Phone], [Home Phone], "No Phone")} \end{aligned} $$
Mobile Phone Null ✕ Home Phone Null ✕ "No Phone" Returned ✓ COALESCE checks left to right, returning the first non-null value Mobile: 555-1234 Returned ✓ (stops here)

Key Distinction: Choosing the Right Function

\(\texttt{IFNULL}\) \(\texttt{ZN}\) \(\texttt{COALESCE}\)
Arguments 2 1 2+
Replacement Any value Zero only First non-null
Data types Any Numeric only Any (must match)
Fallback chain Single Single Multiple
Best for Custom default Quick numeric fix Multi-source merge

Detecting Nulls with \(\texttt{ISNULL}\)

Before replacing nulls, you may need to detect them. The \(\texttt{ISNULL()}\) function returns TRUE if the expression is null, and FALSE otherwise. It is useful for conditional logic and filtering.

$$ \begin{aligned} & \color{#64748b} \texttt{// Syntax} \\ & \texttt{ISNULL(expression) // Returns TRUE or FALSE} \\ & \\ & \color{#64748b} \texttt{// Use in IF statement} \\ & \texttt{IF ISNULL([Profit]) THEN "Missing"} \\ & \texttt{ELSE "Has Data"} \\ & \texttt{END} \end{aligned} $$

Step-by-Step Approach

1
Identify null-prone fields. Check your data source for columns with missing values using \(\texttt{ISNULL}\) or Tableau's data preview.
2
Determine the intent. Should null mean zero, "Unknown", or should it pull from a fallback field?
3
Choose the right function. \(\texttt{ZN}\) for numeric zero, \(\texttt{IFNULL}\) for a custom default, \(\texttt{COALESCE}\) for multi-field fallbacks.
4
Wrap your expressions. Apply the function to the innermost field reference before performing calculations.
5
Validate the output. Spot-check rows that originally had nulls to confirm the replacement is working correctly.

Example 1: Safe Revenue Calculation

Scenario: You need to calculate total revenue as Price × Quantity, but some Quantity values are null.

$$ \begin{aligned} & \color{#64748b} \texttt{// Without null handling (BROKEN)} \\ & \texttt{[Price] * [Quantity] // Returns Null if Qty is Null} \\ & \\ & \color{#64748b} \texttt{// With ZN (FIXED)} \\ & \texttt{[Price] * ZN([Quantity]) // Returns 0 if Qty is Null} \end{aligned} $$
Before \(\texttt{ZN()}\)
Row Result A $2,500 B Null C $400 →
After \(\texttt{ZN()}\)
Row Result A $2,500 B $0 C $400

Example 2: Labeling Missing Categories

Scenario: Your Region field has null values for some rows. You want to label them "Unassigned" so they appear cleanly in filters and legends.

$$ \begin{aligned} & \color{#64748b} \texttt{// Calculated field: Clean Region} \\ & \texttt{IFNULL([Region], "Unassigned")} \end{aligned} $$
Before East West Null South →
After \(\texttt{IFNULL}\)
East West Unassigned South

Example 3: Multi-Source Contact Lookup

Scenario: You have three phone number fields: Mobile, Home, and Work. You want to display whichever one is available, preferring Mobile first.

$$ \begin{aligned} & \color{#64748b} \texttt{// Calculated field: Best Phone} \\ & \texttt{COALESCE(} \\ & \texttt{\quad [Mobile Phone],} \\ & \texttt{\quad [Home Phone],} \\ & \texttt{\quad [Work Phone],} \\ & \texttt{\quad "No Phone on File"} \\ & \texttt{)} \end{aligned} $$
Customer: Alice Mobile: Null Home: 555-9012 555-9012 Customer: Bob Mobile: Null Home: Null / Work: Null "No Phone on File"

Common Mistakes

✕ Using \(\texttt{ZN}\) on Strings
\(\texttt{ZN}\) replaces nulls with zero, which makes no sense for text fields. Use \(\texttt{IFNULL}\) with a string default instead.
✕ Wrapping Too Late
Applying \(\texttt{ZN}\) to the final result instead of the source field. The null has already propagated by then.
✕ Assuming Null = Zero
Blindly converting all nulls to zero distorts averages and hides data quality problems from stakeholders.

Summary: When to Use What

Situation Recommended Function Example
Null number → zero \(\texttt{ZN()}\) \(\texttt{ZN([Sales])}\)
Null string → label \(\texttt{IFNULL()}\) \(\texttt{IFNULL([Region], "N/A")}\)
Null number → custom value \(\texttt{IFNULL()}\) \(\texttt{IFNULL([Discount], 0.05)}\)
Multiple fallback fields \(\texttt{COALESCE()}\) \(\texttt{COALESCE([A], [B], [C])}\)
Detect presence of null \(\texttt{ISNULL()}\) \(\texttt{ISNULL([Profit])}\)

Question 1 of 5

What does the expression \(\texttt{[Price] * [Quantity]}\) return when \(\texttt{[Quantity]}\) is null?

Question 2 of 5

Which function replaces a null value specifically with zero and takes only one argument?

Question 3 of 5

You have three address fields: \(\texttt{[Address1]}\), \(\texttt{[Address2]}\), and \(\texttt{[Address3]}\). You want to display the first non-null address. Which expression is correct?

Question 4 of 5

A calculated field reads: \(\texttt{ZN([Discount]) * [Revenue]}\). If \(\texttt{[Discount]}\) is null and \(\texttt{[Revenue]}\) is 500, what is the result?

Question 5 of 5

Why should you avoid blindly using \(\texttt{ZN()}\) to replace all null values with zero in an average calculation?