How to Make a Stacked Bar Chart in Tableau with AI

Cody Schneider

Creating a stacked bar chart in Tableau is an excellent way to show how a whole is divided into different parts and how those change over time or across categories. This article will walk you through the manual, step-by-step process for building one in Tableau and then show you how modern AI-powered features are revolutionizing the process, letting you build charts with simple text prompts.

What is a Stacked Bar Chart?

A stacked bar chart breaks down and compares parts of a whole across different categories. Each bar represents a total amount, and the segments within that bar represent different sub-categories or components that make up the total. Think of it as a series of pie charts laid out side-by-side, making it easier to compare the total values.

For example, if you have a bar representing total sales for Quarter 1, a stacked bar chart could show that total broken down by segments for "Electronics," "Furniture," and "Apparel." This allows you to see both the total sales for Q1 and the contribution of each product category to that total simultaneously.

When to Use a Stacked Bar Chart

Stacked bar charts shine when you need to show part-to-whole relationships across multiple categories. They are perfect for answering questions like:

  • What are our total sales per region, broken down by product line?

  • How has our website traffic from different sources (Organic, Social, Direct) changed on a monthly basis?

  • What is the division of marketing spend across various channels (Google Ads, Facebook Ads, Email) each quarter?

However, be mindful of their limitations. While they are great for comparing the total length of the bars, comparing the size of individual segments can be tricky, especially for segments that aren't sitting on the baseline. If you need precise comparisons between sub-categories, a different chart type, like a clustered bar chart or a line chart, might be more effective.

How to Manually Build a Stacked Bar Chart in Tableau

Let's walk through the traditional process of building a stacked bar chart in Tableau. Imagine we have a simple dataset of quarterly sales data broken down by product category.

Our sample data might look like this:

Quarter, Product Category, SalesQ1 2023, Electronics, 45000Q1 2023, Clothing, 30000Q1 2023, Home Goods, 22000Q2 2023, Electronics, 52000Q2 2023, Clothing, 35000Q2 2023, Home Goods, 28000Q3 2023, Electronics, 60000Q3 2023, Clothing, 42000Q3 2023, Home Goods, 31000Q4 2023, Electronics, 75000Q4 2023, Clothing, 55000Q4 2023, Home Goods, 40000

Step 1: Connect to Your Data Source

First, open Tableau and connect to your data. This could be an Excel file, a Google Sheet, a CSV, or a direct database connection. For our example, we’ll assume you’ve connected to a spreadsheet containing the data above.

Step 2: Create a Simple Bar Chart

Once your data is loaded, Tableau's interface will display your data fields, categorized as Dimensions (categorical data like 'Quarter' and 'Product Category') and Measures (numerical data like 'Sales').

  1. Drag the Quarter dimension from the Data pane onto the Columns shelf. This will create a column for each quarter in your dataset.

  2. Drag the Sales measure onto the Rows shelf.

At this point, you'll have a standard bar chart showing the total sales for each quarter. This is the foundation of our stacked chart.

Step 3: Stack the Bar Segments

This is where the magic happens. To break down each quarterly bar by product category, you need to use the Color mark.

  • Find the Product Category dimension in the Data pane.

  • Drag Product Category and drop it onto the Color card in the Marks pane.

Instantly, Tableau will segment each bar into colors representing the different product categories. Each colored segment's size corresponds to the sales from that category for that quarter. You now have a stacked bar chart!

Step 4: Refine and Format Your Chart

A good visualization is a clear visualization. Let’s add some finishing touches to make it easier to read.

  • Add Labels: To show the sales figures for each segment, drag the Sales measure onto the Label card in the Marks pane. You can then right-click a label to format the numbers (e.g., add a currency symbol).

  • Adjust Colors: Don't like the default colors? Click the Color card and select "Edit Colors" to choose a new palette or assign specific colors to each category.

  • Sort Your Data: You might want to sort the order of the segments within the bars. You can do this by dragging the 'Product Category' fields within the color legend.

  • Add a Title: Double-click the sheet title ("Sheet 1") to give your chart a descriptive name, like "Quarterly Sales Performance by Product Category."

Variation: The 100% Stacked Bar Chart

Sometimes you’re less interested in absolute sales figures and more interested in the proportional contribution of each category over time. A 100% stacked bar chart is perfect for this. It normalizes each bar to 100%, so you can easily see if, for example, Electronics grew from 40% of sales in Q1 to 50% in Q4.

Converting a standard stacked bar chart to a 100% version in Tableau is simple:

  1. Right-click the SUM(Sales) pill on the Rows shelf.

  2. Select Quick Table Calculation > Percent of Total.

  3. By default, Tableau might calculate the percent of the grand total across all bars. We need to tell it to calculate the percentage within each bar (each Quarter). Right-click the SUM(Sales) pill again, go to Compute Using, and select Table (Down) or Cell. This ensures each bar sums to 100%.

The AI-Powered Way: Using Natural Language in Tableau

Manually building charts is a foundational skill, but modern BI tools are integrating AI assistants that dramatically speed up the process. Tableau's Einstein Copilot (formerly Ask Data) allows you to create visualizations just by typing what you want in plain English.

Instead of clicking and dragging pills, you can simply type a prompt into the tool's interface. For our example, you could write:

“Show me sum of sales by quarter broken down by product category as a stacked bar chart.”

Tableau's AI will parse this request, identify the relevant dimensions and measures ('sales,' 'quarter,' 'product category'), understand the desired chart type ('stacked bar chart'), and instantly generate the visualization for you. It does all the dragging-and-dropping behind the scenes in seconds.

Why This Changes Everything

Using AI for chart creation offers several powerful advantages:

  • Incredible Speed: For both simple and complex charts, typing a sentence is far faster than navigating menus and dragging elements with a mouse. What once took several minutes now takes a few seconds.

  • Lowering the Learning Curve: Learning Tableau takes time. There's a steep curve to understanding Shelves, Marks, Pills, and Table Calculations. AI removes this barrier. If you know what to ask, you can create a chart without knowing the technical "how-to." It makes data more accessible to everyone on the team, not just data specialists.

  • Effortless Data Exploration: AI encourages curiosity. Once you have your first chart, you can ask follow-up questions to iterate. For example:

    • “Now show this as a 100% stacked bar.”

    • “Filter this to only show Electronics and Clothing.”

    • “Swap this to a line chart instead.”

    This conversational approach makes digging into your data feel more like brainstorming with a colleague than performing a technical task.

Tips for Getting the Most Out of Tableau's AI

Prompting AI effectively is a skill. Here are a few tips to get better, more accurate results:

  • Be Hyper-Specific: Don't say "Show sales over time." Instead, say "Show sum of Sales by Quarter." The AI works best when you tell it which fields to use (SUM(Sales), Quarter) and how to aggregate them.

  • State the Chart Type: Explicitly mention the visualization you want: "as a stacked bar chart," "as a line chart," or "as a map." This leaves less room for ambiguity.

  • Know Your Data's Language: The AI isn't magic, it's just parsing your data. You need to use the actual column names from your data source in your prompts. If your column is named "Product_Category," using "product lines" might not work.

  • Refine and Iterate: Your first prompt won't always be perfect. Use follow-up prompts to tweak the result. Ask it to "sort in descending order," "change the colors," or "add labels" to fine-tune the chart.

Final Thoughts

Learning to build a stacked bar chart is a fundamental skill in data visualization, and mastering the process in Tableau gives you fine-toothed control over your output. However, the rise of conversational AI analytics is dramatically changing the workflow, enabling you to move directly from a question to an insight without getting lost in the technical steps.

While Tableau’s embedded AI is a powerful feature for creating individual charts, this conversational approach is just the beginning. At Graphed, we've built an entire platform around this idea, allowing you to connect all your disparate marketing and sales data sources - like Google Analytics, Salesforce, and Shopify - in one place. From there, you can ask plain-English questions to build and share entire real-time, interactive dashboards instantly. Rather than just making one chart, we help you automate the entire reporting workflow so you can get back to making data-driven decisions, faster than ever. Interested? Check out a free account of Graphed today.