Thursday, June 8, 2023

Stacked Bar Chart in Tableau

 A stacked bar chart in Tableau is a visualization that represents the composition of a whole by stacking multiple bars on top of each other
. Each bar segment represents a different category, and the total height of the stacked bars represents the total value. Stacked bar charts are useful for comparing the contribution of each category to the whole and identifying patterns or trends. Here's a step-by-step guide on how to create a stacked bar chart in Tableau with an example.

Stacked Bar chart
Step 1: Prepare your data

Ensure that your data is structured appropriately. It should include categories, subcategories, and their corresponding values to be visualized in the stacked bar chart.

Step 2: Connect to your data source

Launch Tableau and connect to the data source containing your dataset. This can be an Excel file, a database, or any other supported data source.

Step 3: Create a new worksheet

In Tableau, navigate to the worksheet tab and create a new worksheet. This will serve as the canvas for building your stacked bar chart.

Step 4: Drag and drop the necessary fields

From the data pane, drag the dimension field (e.g., category) to the Columns shelf. Then, drag the subcategory field to the Color shelf. Finally, drag the measure field (e.g., value) to the Rows shelf. Tableau will automatically generate a bar chart with multiple bars.

Step 5: Convert to a stacked bar chart

To convert the bar chart into a stacked bar chart, navigate to the Marks card and select the "Stack" mark type. This will stack the bars on top of each other based on the subcategory field.

Step 6: Customize the stacked bar chart

Tableau will generate the stacked bar chart based on your selected fields. However, you can further customize it to enhance readability and provide more insights:

6.1. Format the colors: Click on the "Color" options in the Marks card to modify the colors used in the stacked bars. You can choose different color palettes or assign specific colors to each subcategory.

6.2. Adjust the axis: Right-click on the axis and select "Edit Axis" to modify the range, tick marks, and other formatting options.

6.3. Add labels: If desired, you can add labels to the stacked bars to display the values or category names. Simply drag the desired fields to the Label shelf.

Step 7: Save and share

Once you are satisfied with the stacked bar chart, save the workbook and share it with others. You can export the chart as an image or publish it to Tableau Server or Tableau Public for wider distribution.

For example, let's say you have a dataset that represents the sales figures for different product categories and their subcategories. The sales values for each subcategory within each category are as follows:

Category A:

Subcategory 1: $10,000

Subcategory 2: $5,000

Category B:

Subcategory 3: $7,000

Subcategory 4: $3,000

Category C:

Subcategory 5: $12,000

Subcategory 6: $8,000

By following the steps mentioned above, you can create a stacked bar chart in Tableau that visually represents the contribution of each subcategory to the total sales within each category. The y-axis will represent the sales values, and the x-axis will represent the categories. The stacked bars will show the contribution of each subcategory to the total sales for each category. You can format the colors, adjust the axis, and add labels to enhance the clarity and visual impact of the chart.

The resulting stacked bar chart will enable you to compare the contribution of each subcategory

Thanks for Reading, Subscribe us for more latest Visualization From scratch. 

No comments:

Post a Comment

If you have any doubts. Please let me know

How can you create an alias for a table in a SQL query?

In SQL, you can create an alias for a table in a query to give the table a temporary, alternative name that you can use in the query. Table ...