Stacked Bar Chart in Tableau

Using Tableau, we were analyzing sales performance for our product in each region. I wanted to compare the sales of different product categories in each region.

To visualize this data, I created a stacked bar chart in Tableau that displays the total sales for each region, which are Central, East, South, and West, and stacks them by product category.

In this blog, I will explain what a stacked bar chart is in Tableau and how it can be used to visualize data and show comparisons between categories.

What is a Stacked Bar Chart in Tableau?

In Tableau, or any other data visualization tool, a Stacked bar chart is a type of bar chart that displays the data of different field values into different categories, with each category represented as a segment within the bar. In the stacked bar chart, we can also show sub-categories within a main category.

For example, when analyzing product sales for different regions, a stacked bar chart displays one bar for each region. Each bar is then divided into colored sections representing different product categories. This helps to compare both sales per region and the sales share of each product category within those regions.

In the examples below, I will explain how to create a stacked bar chart using the sample data of the superstore in Tableau. Then we also use Salesforce data to create a stacked bar chart in the second example.

Check out:  Create Pie Chart in Tableau

Create a Stacked Bar Chart in Tableau

In this example, we will create a Tableau that displays statistics on product sales in different regions, categorized by product category.

For this, you can use the existing sample data of the superstore in Tableau Desktop.

  1. After selecting the data source, change the chart type to “Bar” in the “Marks” section.
Create a Stacked chart in Tableau

Check out: Donut Chart in Tableau

  1. The first dimension we will include in the bar chart is the Region; for this, drag the Region to the Columns.
Tableau Stacked bar chart
  1. To display the sales statistics in each region, add the Sales measure to the Rows. Now the bar charts will display the sales stats specific to each.
Add dimension in Tableau Stacked bar chart
  1. To make this bar chart, a stacked bar chart, add the ‘Category‘ dimension from the products in the Color card.

Now the sales stats will be stacked with the product category and show sales for a specific product category in each region.

Add Stacked dimensions in Tableau Stack bar chart

Check out: Stacked Bar Chart With Multiple Measures in Tableau

  1. To display the sales amount for each product category in a specific region, add the Sales measure to the Label card in the Marks section.
Create Stacked Bar chart in Tableau
  1. At last, change the chart view from Standard to Entire View to adjust it to an appropriate proportion.
Stacked Bar Chart in Tableau

This way, we can create a Stacked bar chart in Tableau by following the above steps.

Check out: Waterfall Chart in Tableau

Tracking Monthly Support Cases by Priority Using Tableau Stacked Bar Chart

In this example, we will analyze the Case data, where we will track monthly support cases by Priority level using the stacked bar chart.

To do this, you need to connect the Salesforce data to Tableau Desktop. After setting up the connection, select the Case object and follow the steps below.

  1. Select a new worksheet and select the Marks type as Bar.
Stacked bar chart in Tableau for Salesforce
  1. Drag the created date to the columns. Here, we will analyze the monthly data, so we need to convert the year to a month format.

Right-click on the created date in the column shelf and choose the Month option.

Montth filter in Tableau Stacked bar chart
  1. To count cases per month, drag the Case ID to the Rows shelf. To show the count, right-click on Case ID > Measure > Count.
Stacked Bar chart Measures in Tableau
  1. To stack the cases by priority, drag Priority to the Color on the Marks card. Now, each monthly bar will be stacked into parts for High, Medium, and Low priority cases.
Create Tableau Stacked Bar Chart using Salesforce data
  1. To display the case count in a bar chart, add the Case ID to the Labels card, and here also select the measure as count.
Create Stacked Bar chart in Tableau Desktop

Check out: Divergent Stacked Bar Chart in Tableau

  1. Change the chart to an entire view, now we can see the count of cases in each month, stacked with priority values.
Tableau desktop Stacked bar chart

This way, we can utilize data from external sources, such as Salesforce, and create a stacked bar chart.

By following the above methods, you can easily create a stacked bar chart in Tableau. In the above examples, we have created stacked bar charts using internal datasets, such as the Superstore sample, or external sources, like Salesforce.

Agentforce in Salesforce

DOWNLOAD FREE AGENTFORCE EBOOK

Start with AgentForce in Salesforce. Create your first agent and deploy to your Salesforce Org.

Salesforce flows complete guide

FREE SALESFORCE FLOW EBOOK

Learn how to work with flows in Salesforce with 5 different real time examples.