Creating a stacked chart in Tableau is a powerful way to compare and contrast data, especially when dealing with multiple dimensions or measures. This type of chart allows you to visualize the composition of a whole by breaking it down into its constituent parts. Let's dive into a step-by-step guide on how to create a stacked chart in Tableau.

Before we begin, ensure you have Tableau installed on your computer and a dataset ready to use. For this guide, we'll use a sample Superstore dataset that comes with Tableau.

Preparing Your Data
To create a stacked chart, you'll need to have your data structured in a way that allows for comparison. For instance, you might have sales data for different categories (e.g., Furniture, Office Supplies, Technology) and you want to compare the sales performance of each category over time.

In our Superstore dataset, let's focus on the 'Category', 'Sub-Category', 'Order Date', and 'Sales' fields. We'll use 'Category' and 'Sub-Category' for the dimensions, 'Order Date' for the axis, and 'Sales' for the measure.
Creating a Simple Bar Chart

First, let's create a basic bar chart to serve as our foundation. Drag the 'Order Date' field to the Columns shelf and 'Sales' to the Rows shelf. Your chart should now display sales over time.
To make it easier to read, right-click on the 'Order Date' field in the Columns shelf and select 'Months'. This will aggregate your data by month instead of individual days.
Creating the Stacked Chart

Now, let's turn this bar chart into a stacked chart. Drag the 'Category' field from the Dimensions pane and drop it onto the Color mark card. Your chart should now display sales by category, with each category represented by a different color.
However, this is not yet a stacked chart. To create a stacked chart, you need to add another dimension to the Color mark card. Drag the 'Sub-Category' field and drop it onto the Color mark card, placing it inside the 'Category' field. Your chart should now display a stacked chart, with each sub-category within a category represented as a stacked bar.
Customizing Your Stacked Chart

Now that you have a basic stacked chart, you can customize it to better suit your needs. For instance, you might want to sort your categories or sub-categories in a specific order. You can do this by right-clicking on the field in the Color mark card and selecting 'Sort'.
You can also add a title to your chart by right-clicking in the empty space of the chart and selecting 'Format'. Then, go to the 'Title' tab and enter your desired title.




















Adding a Trend Line
To add a trend line to your stacked chart, right-click on the 'Sales' field in the Rows shelf and select 'Trend Line'. This can help you visualize the overall trend of your data, even with the stacked bars.
You can customize the trend line by right-clicking on it and selecting 'Format'. Here, you can change the line color, style, and weight.
Adding a Reference Line
Another useful feature is adding a reference line to your chart. This can help you compare your data to a specific value. To add a reference line, right-click on the 'Sales' field in the Rows shelf and select 'Reference Line'.
You can then customize the reference line by right-clicking on it and selecting 'Format'. Here, you can change the line color, style, and weight, and also set the value of the reference line.
And there you have it! You've now created a fully customized stacked chart in Tableau. This type of chart is incredibly useful for comparing and contrasting data, and with Tableau's customization options, you can make it uniquely your own. Now go forth and start creating insightful stacked charts!