How to create a stacked bar chart that adds up to 100% in Tableau?

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.

Screen Shot 2017-07-05 at 8.56.43 PM.png

Screen Shot 2017-07-05 at 8.55.48 PM.png

Step 2. Drag Visits to row shelf. Graph type is Bar.

Screen Shot 2017-07-05 at 9.02.34 PM.png

Step 3. Drag Device Category to Color.

Screen Shot 2017-07-05 at 9.06.45 PM.png

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).

Screen Shot 2017-07-05 at 9.08.52 PM.png

Screen Shot 2017-07-05 at 9.09.14 PM.png

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.

Screen Shot 2017-07-05 at 9.15.57 PM.png

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.

 

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s