When creating a stacked bar chart in Tableau, it’s common to encounter situations where the default settings might not align with your specific visualization needs. For instance, you might want to display a single label representing a total value instead of individual labels for each stack within the bar. To address this, follow these steps:
Construct Your Stacked Bar Chart: Begin by setting up your stacked bar chart using the necessary data, as shown in the example below:
Duplicate the Chart: Duplicate the chart within the same sheet by copying the measure. For instance, if your measure is SUM(Sales), replicate it as shown in the example:
Customize Chart Layers: With two charts available, modify one to reflect a specific measure (e.g., SUM(Sales) by Category) and the other to display a more detailed level of data (e.g., SUM(Sales) by Sub-Category) or another relevant measure.
To do this, you need to first adjust the second Marks Card by changing the chart type to Gantt-Bar. Then remove the dimension responsible for creating stacked bars (e.g., Sub-Category). After that add the desired label (e.g., Profit measure) to display atop the bars and customize the label settings to show it as you want, in this case I added ‘’Total Profit” to make the distinction between labels. Then set the Color Mark opacity to 0% to render the Gantt-Bar invisible, leaving only the label visible.
Once you have your bars and labels ready you need to create a Dual Axis and Synchronize it: Expect the chart type to temporarily change during this process. You can do these steps by right-clicking on the axis. Then hide the duplicate right axis by right-clicking on the axis and deselecting “show header.”
Adjust Chart Type and Labels back: Restore the original chart type to Bars in the first Marks Card and configure the labels according to your preferences. For example, in the first Marks Card, display Sales by Sub-Category, so we can have both sales by Sub-Category and Total Profit by Category shown in one chart, as depicted in the image below:
With this technique, you can effectively showcase diverse values or varying levels of granularity within a single, refined chart.