Unit charts
Click to view on Tableau Public
Unit charts are a common chart type in data visualization and are great for seeing composition of a particular metric. You can think of unit charts as a stacked bar chart where the dimension is the child of a parent dimension.
This #WorkoutWednesday challenge from week 45 of 2023 challenges us to make a unit chart with some additional functions such as filtering, color and sorting of the child dimension. I really like this challenge because it utilizes a highlight and sort rather than a filter.
Check out my solution video below and my custom calculations are below the video if you are working along with the video
The calculations
After we create our parameter we need to bring it into our datasource by evaluating if the tag field CONTAINS our parameter selection substring
//Wine contains pairing
[Food Selector_EN]="All" or
CONTAINS([Tags],[Food Selector_EN])
We’ll duplicate this field and swap out the translation for “All” and flip our parameter being evaluated to the BR words
Next we’ll create our sort field to ensure the selected or highlighted wines fall to the start of the unit chart. We’ll use this to sort the field on the label shelf of the mark’s card
//wine sort
if [Wine contains pairing] then 1 else 0 END
GO FORTH AND VIZ!