This falls into the confusing and complex area of data densification --- Tableau creating values where none exist.
I usually try to avoid Tableau data densification by fixing the issue in the data with either a scaffold data source or modifying the data directly to include null or 0 values for the combinations of dimensions I need to display fully or to blend -- this is the most robust path against filtering and the various rules Tableau applies to missing data.
But I did get your issue resolved by converting the age group field to a range-aware pill and then using show missing values.
I'll describe what I think is happening below, but the basic technique is to
1. convert age group to an integer using a case statement (
CASE [Age Group]
WHEN "10-14" THEN 1
WHEN "15-19" THEN 2
WHEN "20-24" THEN 3
2. create a bin field with bin size 1 -- bins and dates are "range-aware" dimensions.
Replace Age Group with this pill. After adding the pill to the view, right-click > Show Missing Values
3. alias the bins from 1, 2, 3 back to 10-14, 15-19, 20-24, etc. Right click the field in the left data pane > Edit Aliases.
Now you can filter the years and get both the complete set of age groups (domain padding using show missing values) and a break in the line where no data exists.
Here's the longer version.
- Tableau treats line, area and polygon mark types differently than other mark types such as bar graphs for data densification. I don't know why, but I assume Tableau is trying to do what usually works. I.e., people usually like their lines and area charts connected (even if it can cause confusion).
- There are two general types of data densification:
- Domain Completion --- show empty rows / columns is the easiest example.
- Domain Padding --- show missing values on range-aware pills (dates and bins mostly)
- In your example, domain completion is triggered with the show empty columns option in the Analysis > Table Layout menu.
- But Tableau doesn't treat this as null for the purpose of the line graph formatting.
- Not really sure why. But there is a deceptively complex order of operations behind Tableau's viz flow.
- You can enable domain padding by using the context menu on a range-aware pill. Click Age Group Int Bin > show missing values.
- For the purposes of marks, Tableau treats domain padded values as null and, therefore, you can use the line formatting to either break the lines or show the null values as zero.
This isn't a perfect solution, as domain padding will aways show extra marks. For example, instead of using aliases you might try just dropping the age group dimension on the Columns thinking that becuase there is a 1-to-1 relationship between age-group and age-group int bin, you will get 1 age group mark for every bin. Turns out you get a complete set of age group bin marks for each age group.
Cases_jimw.twbx 76.3 KB
Jim, many thanks for this detailed reply. This is really helpful, and is greatly appreciated!