# ZN Function in Tableau

> This is content from just-tim, the data-and-analytics channel by Tim Ngwena (formerly 'Tableau Tim'). Tim has 12+ years of hands-on BI experience and covers Tableau most of all, plus Power BI, Looker, Hex, SQL and data modelling, the analytics industry, and the craft of doing the job — always tool-agnostic and honest about the trade-offs.

- **Author:** Tim Ngwena (just-tim, https://just-tim.com/about)
- **Published:** 2021-02-04
- **Format:** Video · 7 min watch · transcript available
- **Topics:** Data prep, Data visualisation
- **Tools:** Excel; Tableau (calculated fields, zn)
- **Canonical:** https://just-tim.com/posts/zn-function-in-tableau
- **Watch:** https://youtu.be/-etGzF433n8

I walk through the ZN function in Tableau, which replaces null values with zero. Using a mock cinema revenue data set, I show how nulls can quietly skew calculations like averages, and how ZN keeps your aggregations accurate and your dashboards clean.

## Key takeaways

- 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'

## Chapters

- 0:00 What the ZN function does
- 0:21 Exploring the mock data set
- 0:59 Connecting the data in Tableau
- 1:41 Spotting the null problem
- 2:06 Writing the ZN calculation
- 3:25 How nulls skew your averages
- 4:55 Cleaning data and improving literacy

Watch the full video, read the transcript and use chapter deep-links on the page: https://just-tim.com/posts/zn-function-in-tableau

---
just-tim — Data and analytics, with a point of view. · https://www.youtube.com/channel/UC7HYxRWmaNlJux-X7rNLZyw · https://twitter.com/TableauTim · https://www.linkedin.com/in/timngwena
