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.
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.
Why Nulls Break Dashboards
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.
The Three Null-Handling Functions
\(\texttt{IFNULL}\): The Custom Replacement
\(\texttt{ZN}\): Zero for Null
\(\texttt{COALESCE}\): Cascading Fallback
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.
Step-by-Step Approach
Example 1: Safe Revenue Calculation
Scenario: You need to calculate total revenue as Price × Quantity, but some Quantity values are null.
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.
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.
Common Mistakes
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?