Get Ready For Your Tableau Certification
  • Bernard

Stacked Bar Chart in Tableau


Stacked bar chart in Tableau

Definition

Stacked bar/column chart is used to show comparison between categories of data, but with ability to break down and compare parts of whole.

Each bar represents whole with segments of the bar representing different parts of the whole.

Example of a stacked bar/column chart

example of a stacked bar chart

Note: The difference between bar and column chart is the alignment. Where, bar chart is aligned horizontally while column chart is aligned vertically.

Therefore, in this post I will be sharing different ways you can create a stacked bar/column chart in Tableau.

Stacked bar chart using separate bar for each dimension.

In this case am going to use Sample-Superstore data set to create a stacked bar chart showing sale by Region broken down by product category.

Option 1

  • Drag dimension Region to the column shelf.

  • Drag measure Sales to the row shelf.

  • Drag dimension Category to the color shelf.

  • Label this view.

Stacked bar chart using separate bar for each dimension

Option 2

  • Drag dimension Region and Category to the column shelf.

  • Drag measure Sales to the row shelf.

  • Select Stacked bars under the Show Me tab.

Executing this and labelling the view we’ve.

Stacked bar chart using separate bar for each dimension.

Stacked bar chart using separate bar for each measure.

In this case, we are going to create a stacked bar chart showing different measure fields broken down by product category.

  • Drag Measure Names to the columns shelf.

  • Drag Measure Values to the rows shelf.

Filter-out measure fields not to be shown on your view. In this case am going to use the measure field, Profit, Sales, Discount and Quantity.

Execute this and add product category to the color shelf.

Stacked bar chart using separate bar for each measure

Diverging stacked bar chart

Sometimes you can also show a stacked bar chart in the form of a divergent bar chart (known as diverging stacked bar chart). In this case we’re going to compare ‘2020 Sales’ and ‘2021 Sales’ for different Region’s broken down by product category.

But first, explore how to create a divergent bar chart in Tableau.

Helpful: Learn two ways of creating a divergent bar chart in Tableau.

After you create a divergent bar chart comparing ‘2020 Sales’ and ‘2021 Sales’ by Region.

  • Drag product Category to the color shelf.

  • And label the view.

diverging stacked bar chart

Stacked bar chart percent labels.

Sometimes you need to show the proportion of total in percent, instead of showing the actual metrics. You can do that by adding a quick table calculation ‘Percent of Total.’

For example, in this case am going to add percent labels by going to Sales and add table calculation ‘Percent of Total’.

adding percent of total labels to a stacked bar chart

Note, by default this table calculation is computed across the view, that’s the reason why the sum of different categories per region do not add to 100%.

See below.

To correct this, compute the table calculation using ‘Table (down)’ or the dimension used to break down the view, in this case ‘Category’.

Executing this we’ve.

labelling stacked bar chart

Which shows the proportion of sales by product category in different regions.

Note: The same procedure applies for other variations of stacked bar charts described in this article.

Alternative to stacked bar chart

Stacked bar chart is used to do part to whole analysis (proportion of total), alternative charts to this chart include, pie chart, donut (doughnut) chart, waffle chart, treemap, waterfall chart, funnel chart, stacked area chart etc.

I hope this post was helpful to you. To receive more of the Tableau tips and tricks, kindly join our mailing list by subscribing below.

Thank you for reading.

1.png
2.png