ZN Function in Tableau
Find out why you need to know about this function and how to use it.
- ZN() returns the expression if it isn't null, otherwise returns zero, making it ideal for handling nulls in number fields
- Nulls left untreated can throw errors or silently skew aggregations like averages, leading to misleading results
- Wrapping a field as ZN([Revenue]) and prefixing the calculated field name makes it clear you're handling nulls
- Use the calculation editor's function panel to validate what ZN does before applying it
- Replacing null with zero improves data literacy since most business users don't understand the term 'null'
The ZN function replaces null values with zero in Tableau, which stops nulls silently skewing calculations like averages and keeps dashboards easier for non-technical users to understand.
Tim uses a mock cinema revenue data set with some empty revenue values by country and genre, connected from Excel. At a high level of aggregation the nulls aren't visible, but they cause problems once you drill into detail or run aggregations like averages.
- What ZN does 0:00
ZN is a number function that returns the expression's value if it isn't null, or zero if it is. It's built specifically for handling nulls wherever they crop up in a numeric field.
- Spot the null problem first 1:41
Nulls can hide at aggregate levels of a view and only reveal themselves once you break data down further (e.g. by adding more dimensions). Before reaching for ZN, drill into detail to confirm nulls are actually present and causing an issue.
- Write the calculation 2:06
Wrap the field in ZN(), e.g. ZN([Revenue]), and prefix the calculated field's name with ZN so it's clear to you and others that null-handling is happening there.
- Validate before you trust it 2:41
In the calculation editor, expand the function panel and click on ZN to see its description confirming it returns the expression if not null, otherwise zero — a quick way to check you understand what a function does before applying it.
- Why untreated nulls are risky 3:25
Left alone, nulls can throw errors in calculations or, worse, silently skew results like averages because Tableau may exclude or mishandle them rather than treating them as zero.
- See the effect on an average 4:01
Tim changes an aggregation from sum to average with the raw revenue field and gets a value that looks fine but is wrong, because rows with null revenue are treated inconsistently rather than counted as zero sales.
- Compare against the ZN'd field 4:55
Swap in the ZN-wrapped field and recompute the same average — the result changes once the zero values are properly counted, showing the true average rather than one distorted by ignored nulls.
- Clean data improves literacy 5:41
Beyond fixing maths, ZN removes the term 'null' from dashboards. Most business users don't have the data literacy to understand null versus zero, so presenting a clean zero avoids confusion and explanation overhead.
- Nulls can look completely fine at a high level of aggregation and only surface once you add more granularity to the view, so don't assume a clean-looking summary means clean data.
- Close the source Excel file before connecting to it in Tableau, as a live open file can cause connection issues.
- Dropping a field into a box that already holds another measure can trigger Measure Names/Measure Values and complicate the view — expected behaviour, not an error.
Reach for ZN whenever a numeric field has nulls that could distort aggregations like averages, or when you want to present a clean zero instead of a null on a dashboard for less technical audiences.
How this Rollup was made provenance & method
A Rollup is drafted by AI from the video's transcript, then reviewed and edited by Tim. Everything used to produce this one is listed below — the model, the exact prompt, and the source video — so the process is transparent and reproducible.
- Transcription
- On-device — NVIDIA Parakeet v3 for recent videos, OpenAI Whisper large-v3 for earlier ones. The transcript never leaves the machine or gets published.
- Drafting
- Claude Sonnet 5 in the cloud, from that transcript.
- Prompt
- The exact Rollup prompt (v2) — the full system prompt, unedited.
- Source video
- Watch on YouTube
- Drafted
- 5 July 2026 at 09:38
- Reviewed & edited
- 5 July 2026 at 09:41 · by Tim Ngwena
Model + prompt + video is everything you'd need to recreate a Rollup like this yourself. The one thing we don't share is the transcript.
Rights. The video and its transcript are the property of TN Media Ltd. Unauthorised use or download is prohibited. © TN Media Ltd.