Mastering Bar within Bar Charts in Tableau

Suparna Chowdhury
5 min readJun 3, 2023

--

A comprehensive guide to visualizing and analyzing categorical data

Image by Mediamodifier from Pixabay

Bar charts are very popular and effective way to visualize and analyze categorical data and compare values across different categories. Bar charts are particularly effective when we want to represent numerical data categorized into different groups. Tableau offers a range of options to create visually compelling and insightful bar charts.

In this article, we will explore how to create different types of bar within bar charts in Tableau. A bar within a bar chart becomes particularly useful when comparing two measures within a single dimension or when comparing a dimension across two or more time periods. By the end of this article, you will have the knowledge and skills to create 3 different types of bar in bar chart. Let’s dive in and discover the diverse possibilities of creating bar in bar charts.

We will use Tableau Superstore Dataset as it provides a diverse collection of numerical data across various categories and make it an ideal source to showcase different bar charts.

Bar in Bar Chart By Dimension (Method 1):

In this chart we want to compare Sales of 2 years — 2022 and 2021 By Region

  1. Connect the data source to Tableau and create a new sheet.
  2. First create two calculated fields for current year (e.g. 2022) and last year (2021).

Sales Current Year:

SUM(INT(YEAR([Order Date])={YEAR(MAX([Order Date]))}) * [Sales])

Sales Last Year:

SUM(INT(YEAR([Order Date])={YEAR(MAX([Order Date]))}-1) * [Sales])

2. Drag both Sales Last Year and Sales Current Year to the Column shelf. Drag the Dimension you want to use (e.g. Region) to the Rows Shelf.

3. Right Click on the Sales Current Year pill and check Dual Axis. Click any axis in the visualization check Synchronous Axis. It may change the visual to dots.

4. Go to All Marks card, change Automatic to Bar.

5. Create a calculated field for color.

Sales CY vs LY: [Sales Current Year]>=[Sales Last Year]

Drag the calculated field to the Colour Shelf in the AGG(SalesCurrent Year) Marks Card. Change color as you desire. Reduce the width of the bar by lowering the slider in the Size shelf

6. Customize the appearance of your chart by adjusting colors, labels, and other formatting options as desired.

Bar in Bar Chart by Dimension

2. Bar in Bar Chart By Dimension (Method 2):

In this chart we want to compare Sales of 2 years — 2022 and 2021 By Region

  1. Drag Order date ( Discrete Year(Order Date)) to the Filters Shelf and check 2022 and 2021. Click OK.

2. Drag the measure you want to use (e.g., Sales) to the Column shelf.

3. Drag the Dimension you want to use (e.g. Region) to the Rows Shelf

4. Ctrl + Drag the same filtered field Year(Order Date) from Filter Shelf to

the Colour Shelf in the Marks Card.

5. From Analysis tab in the Menu bar, Click Stack Marks -> Off

6. Ctrl + Drag to copy the same filtered field Year(Order Date) from the Filter Shelf to the Size shelf in the Marks Card.

7. Customize the appearance of your chart by adjusting colors, labels, and other formatting options as desired.

Bar in bar chart by dimension

3. Bar in Bar Chart by Measures:

In this chart we want to compare two measures — Total Sales and Total Profit by Region

  1. Drag the two measures you want to use (e.g., Sales and Profit ) to the Columns shelf.
  2. Drag the Dimension you want to use (e.g. Region) to the Rows Shelf. Tableau will produce 2 bar charts.

3. Drag and drop the Sum(Profit) pill from the Column shelf to the Sales Axis to make a combined (Shared) Axis chart.

Combined axis chart:

4. From Analysis tab in the Menu bar, Click Stack Marks -> Off

5. Drag the “Measure Names” pill from the Rows shelf to the Colour shelf in the Marks Card. Also Ctrl + Drag the “Measure Names” pill to the Size shelf in the Marks Card.

7. Customize the appearance of your chart by adjusting colors, labels, and other formatting options as desired.

Bar in Bar Chart by Measures

In conclusion, Tableau provides a powerful platform for creating bar within a bar charts which can elevate your data visualization to the next level. Whether you are analyzing sales data or exploring market trends, the bar in bar chart in Tableau provides a visually compelling and informative representation.

Thank you for reading this article. I hope this article has equipped you with the knowledge and inspiration to create some captivating and informative visualizations. Happy charting!

--

--

Suparna Chowdhury
Suparna Chowdhury

Written by Suparna Chowdhury

Hey! I'm into all things data—data science, machine learning, SQL, and Tableau. Join me as I simplify complex ideas and explore the power of data!

No responses yet