It has been a while since I’ve shared a Tableau Tip and I thought it might be useful to share something I did on Watch Me Viz at the Tableau Conference on Tour in London. I wrote about the conference here.
The tip itself is quite simple but one you may try and solve using LOD’s or other complex calculations involving parameters.
Here’s the question:
“A CEO of a company with a number of brands wants you to show the market share of each company, but wants to see one company at a time and to have the ability to select it from a filter.”
You may have noticed I have lousy imagination when it comes to brand names and also that I have a geographic dimension. These are postcode districts for London only. Our CEO wants to see a map of the market share in London, but you can apply the same principle to a KPI or any chart.
Unfortunately the way the data is structured it will give us the brands as separate measures when we really need them as a dimension, and one single measure. Fret not, Tableau allows you to pivot the brands and structure the data correctly. See below:
Once the data is correctly structured we need to create our London map:
Next step is to create our market share, in order to do this we will use the quick table calculation from Tableau, Percent of Total, computing by Brand. To do this we’ll need to bring our Brand to detail first.
At this point if you are new to Tableau you may be thinking – “Well I can just bring brand to filter and be done with it.” Unfortunately table calculations operate on the results of the query to the data source, therefore adding a filter would result in all your districts to show 100% like in the image below.
Here’s the trick, instead of adding brand filter to the filter shelf create the following calculated field and add it to the filter shelf. Make sure it computes using brand.
The calculated field works because it looks for the brand you’ve selected and hiding all others while keeping them within the table used by the quick table calculations.
This is the final result:
As I’ve mentioned at the start, you may wish to use a combination of parameters and LOD’s to get the same result, but that’s the beauty of Tableau, there are often many solutions to the same problem.
Thank you for reading, I hope you have found it useful