Data Science

How can I force Tableau to display a zero instead of a blank space when there is no data?

SA Asked by Sarah Jenkins · 14-06-2024
0 upvotes 15,723 views 0 comments
The question

I am currently building a sales performance dashboard in Tableau and I’ve run into a frustrating issue. When a specific region has no sales for a particular month, the cell in my text table appears completely empty or the mark disappears from my line chart. This makes the report look incomplete. I need to show a '0' in these instances so the stakeholders can see there was activity tracked but no results. What is the most reliable calculation or formatting trick to ensure these Null values are treated as zero across my entire workbook?

3 answers

0
MA
Answered on 15-06-2024

The most straightforward way to handle this in Tableau is by using the ZN() function, which stands for "Zero if Null." You can wrap your measure in this function within a calculated field, like ZN(SUM([Sales])). This tells Tableau to return the sum if it exists, and a zero if the result is null. However, if the data literally doesn't exist in your underlying source (a missing row rather than a null value in an existing row), ZN() might not work on its own. In those cases, you need to go to the top menu, select Analysis > Layout > Show Empty Rows/Columns. This forces Tableau to create a placeholder for every possible dimension combination, allowing the ZN() function to finally find a "spot" to place that zero.

0
RI
Answered on 17-06-2024

Are you finding that the zeros are appearing in your text tables but the lines in your line charts are still breaking or showing gaps? I ask because the fix for a table visualization is often different than the fix for a trend line, where you might need to use a Table Calculation like LOOKUP(SUM([Sales]), 0) wrapped in a ZN() to bridge the missing dates in your timeline.

DA 18-06-2024

Richard, that is exactly what is happening! My line chart looks like a series of disconnected dots instead of a continuous line because of those missing months. If I use the LOOKUP method you mentioned, do I need to set the "Compute Using" settings to a specific dimension, or will it automatically detect the date axis on my columns shelf to fill in those missing zeros correctly?

0
JE
Answered on 20-06-2024

You can also try right-clicking the measure in the view, selecting 'Format', and under the 'Pane' tab, find the 'Special Values' section. There you can set 'Marks' to 'Show at Default Value' which is 0.

SA 21-06-2024

Jennifer's formatting trick is a great "no-code" solution! It’s much faster than creating a dozen calculated fields if you just need it for one specific chart. Just be careful, because formatting only changes the display—if you use that field in another calculation, it might still be treated as a Null unless you use Margaret's ZN() approach.

Share your thoughts

Your email address will not be published. Required fields are marked (*)

Professional Counselling Session

Still have questions?
Schedule a free counselling session

Our experts are ready to help you with any questions about courses, admissions, or career paths. Get personalized guidance from industry professionals.

Request a Call Back

Search Online

We Accept

We Accept

Follow Us

"PMI®", "PMBOK®", "PMP®", "CAPM®" and "PMI-ACP®" are registered marks of the Project Management Institute, Inc. | "CSM", "CST" are Registered Trade Marks of The Scrum Alliance, USA. | COBIT® is a trademark of ISACA® registered in the United States and other countries.

Book Free Session