Using the ZN Function in Tableau

by Carlo Sanzeri

Today I will be going through one of the most popular use cases of the ZN (Zero/Null) Function in Tableau.

First off, for this I will be using a mock dataset for a fake company that looks like this:

As you can see, we have one field for employee name, and another for which department they belong too. We then have their sales - which due to poor data quality, has a lot of nulls.

Nulls can be extremely detrimental to any aggregations we make in Tableau, as these figures can be totally ignored, and that's where the ZN function comes into play. Let's say we want to take the average sales for each department - lets see what that looks like without ZN.

Looks pretty normal, and nothing seems wrong, right?

Now let's build out a calculated field where we use the ZN function to replace all those nulls with zeros.

It's so easy to apply this function

Now, let's see what the average looks like when we use this field compared to the original dataset.

As we can see our figures have dramatically changed. So, next time you're using a dataset with a lot of nulls where there should be zeros, make sure you use the ZN function to make sure you're getting accurate results out of your data.