While analyzing our company’s sales data, I wanted to compare sales by region to see the contribution of each product Category (Furniture, Office Supplies, Technology).
For this, I created a stacked bar chart where each bar represented the sales of a region and was divided into different categories.
Through this Stacked chart, the sales team found it difficult to understand the total sales per region since only the individual category contributions were visible in bars.
To make the visualization easy, I needed to add totals on top of each stacked bar, so that even though the bars are divided into categories, the overall regional sales total is clearly displayed.
In this Tableau tutorial, I will explain how to add the total of values in a Tableau Stacked Bar Chart.
Add Total of Values in Tableau Stacked Bar Chart
There are two methods through which we can add the total of all values in the Tableau stacked bar chart.
- Add Total in Tableau Stacked bar chart using dual-axis
- Add Total in Tableau Stacked Bar Chart using Reference Lines
Add Total in Tableau Stacked Bar Chart Using Dual-Axis
For this Tableau stacked bar chart, we will use the Tableau superstore data set to show the total of values at the top of stacked bars.
Now, connect the datasource with Tableau and follow the steps below to create a stacked bar in Tableau and show the total of values.
- To compare the Sales of product categories across regions, add the Sales to Rows and Region to Columns.

- To distribute the sales of the region, we will stack the bar using the category. For this, add the Category to the Color card in the Marks section.

- To add the values of stacked measures and the total at the top of bars, we will create a dual axis. For this duplicate, the Sales on the Rows and change the Marks type to Gantt bar.

- Now, click on the second sales in the Rows and select Dual Axis.

- Now, remove the Category(Color) from the second Sales axis.

- Now, we will add the labels for the values in both charts ( Gantt chart and Bar chart). The values in the Sales(1) chart will show the stacked values, and Sales(2) will show the values at the top of the stacked bar.

- If the values are not aligned at the top of the bars, then right-click on the Sales axis and select Synchronize Axis.

With this, the total of the values will be stacked at the top of the bars as shown in the image below.

This way, we can add the total at the top of bars in Tableau Stacked bar charts using the Dual-axis charts.
Add Total in Tableau Stacked Bar Chart Using Reference Lines
In this method, we will use the reference lines to show the total of stacked values at the top of the bars.
- Add the Region to Columns, Sales to Rows to show sales in various regions. Then, stack it by adding the Category in the Color card of the Marks section.

- To add the reference line, right-click on the Sales axis and select Add Reference Line.

- Now, configure the reference line in the following way to show the total at the top of stacked bars.
- In the dialog box, set Scope = Per Cell so that each Category gets its own total.
- For Value, choose SUM(Sales).
- Under Label, select Value to show the total number at the end of each stacked bar.
- Format the line as None (remove the actual line) so only the total label appears at the top.

- Now the total of stacked values will appear at the top of the bars. If the total value is not aligned, then click on the value and select Format.

- In the Reference Line Label, select Alignment as Middle. With this, values will be aligned at the top-center of the bars.

- We can also display the sales values for each category in the stacked bars. For this, select Marks -> Label -> Show mark labels.

Now, we can see the sales values for each category and also the total Sales for each region in the Tableau stacked bar chart.

This way, we can show the total values in Tableau stacked bar charts by using the reference lines.
Conclusion
In this Tableau tutorial, we have learned how to add the total of values on top of stacked bar charts. In the above examples, we used two methods to show the total values in stacked bars. One using a Dual-Axis and the other using Reference Lines.
By using either of these two methods, you can easily display the overall measure total in a stacked bar chart, while still keeping the distribution by categories visible.
You may also like to read:
- Create Slope Chart in Tableau
- Create a Circle Timeline Chart in Tableau
- Create Candlestick Chart in Tableau
- Create a 100% Stacked Bar Chart in Tableau
- Show Top N Results in Tableau Chart
I am Bijay Kumar, the founder of SalesforceFAQs.com. Having over 10 years of experience working in salesforce technologies for clients across the world (Canada, Australia, United States, United Kingdom, New Zealand, etc.). I am a certified salesforce administrator and expert with experience in developing salesforce applications and projects. My goal is to make it easy for people to learn and use salesforce technologies by providing simple and easy-to-understand solutions. Check out the complete profile on About us.