All Collections
FAQs
How can I create a 100% stacked bar chart?
How can I create a 100% stacked bar chart?

100% stacked bar chart, percent stacked bar chart

Katie Hindson avatar
Written by Katie Hindson
Updated over a week ago

In this article, we'll learn how to make a bar chart that's stacked to 100%, like this:

To build bar charts stacked to 100%, you first need to build a stacked bar chart.

That means, you need at least 2 dimensions (one x-axis, and one group) and a metric on your y-axis.

You can add groups to your chart in the chart config panel, at the bottom. You'll also see the option to stack at the bottom - toggle this option to stack.

Next, you need to add a table calculation to calculate the % contribution of each group to the total.

To do this, click on the toggle for the metric you want to plot on your chart, then select percent of column total from the quick calculations.

Now, we need to edit this calculation and add a PARTITION BY clause.

The table calculation should have a bit that looks like OVER(). You're going to add some logic to this part of the calculation.

The dimensions that you have in selected as your groups in your chart configuration, you're going to add them to this part of the table calculation after writing PARTITION BY.
โ€‹
For example, the group in my chart from above was the created date month from the Users table. So, I'm going to add this field to my table calculation like this:

Finally, we need to update our chart to use this table calculation on the y-axis.

Once we've updated our table calculation to use the same grouping as our chart, we need to replace our y-axis to use this calculation (instead of our original metric).

Now, you should have a stacked bar chart where each stack adds up to 100%

Did this answer your question?