Bar char is probably one of the simplest charts that every data analyst uses all the time. It is simple but very effective. I am working on a web traffic report, which needs to compare website visits by device category (desktop, mobile and tablet) over time. I think a stacked bar chart could be applied to this case. Instead of comparing total number of visits, I care more about the percentage of visits by device category. Today, I will show you how to create a stacked bar chart that adds up to 100% in Tableau.
Step 1. Drag Date to column shelf. Make sure you choose Discrete Exact Date by right clicking Date on column shelf.
Step 2. Drag Visits to row shelf. Graph type is Bar.
Step 3. Drag Device Category to Color.
Step 4. Instead of showing total visits comparison, I would like to present % of visits per device every day. Right click Sum(Visits) on Row shelf, then click Add Table Calculation. Calculation Type is Percentage of Total and Computing Using is Table (down).
Step 5. Command (or Ctrl) + drag Sum(Visits) table calculation to Label mark in order to show the percentage of total visits per device on the stacked bar graph.
It is done! The key to create a stacked bar chart that adds up to 100% is the usage of table calculation. Tableau provides powerful functions of table calculations and window calculations. I will show you more in my next blogs.