Skip to content

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.

Tableau Playbook - Side-by-Side Bar Chart

Sep 4, 2019 • 12 Minute Read

Introduction

Tableau is the most popular interactive data visualization tool, nowadays. It provides a wide variety of charts to explore your data easily and effectively. This series of guides - Tableau Playbook - will introduce all kinds of common charts in Tableau. And this guide will focus on the Side-by-side Bar Chart.

In this guide, we will learn the side-by-side bar chart in the following steps:

  1. We will start with an example chart, then introduce the concept and characteristics of it.

  2. By analyzing a real-life dataset: survival of Titanic passengers, we will learn how to build a side-by-side bar chart step by step. Meanwhile, we will draw some conclusions from our Tableau visualization:

    1. Build the chart based on the basic process.
    2. Optimize and polish the chart with advanced features.
  3. Introduce the related charts and make a comparison of bar chart variations.

Getting Started

Example

Here is a side-by-side bar chart example from Speros Misirlakis's blog.

From the above chart, we can see the measure is job numbers, the first dimension is program languages, and the second dimension is the year.

Just as the literal meaning would lead you to imagine, this chart compares the program languages for 2017 and 2018 jobs side by side. It is much more explicit than two separate bar charts. To help readers comprehend, a side-by-side bar often uses different colors to distinguish bars.

Side-by-Side Bar Chart vs. Stacked Bar Chart

As a variation of a bar chart, a side-by-side bar chart is similar to a stacked bar chart, except it puts bars side by side instead of stacking them.

Both side-by-side bar and stacked bar charts add a second dimension based on a standard bar chart. But stacked bar charts tend to show the part-to-whole relation. By contrast, side-by-side bar charts focus on the sub-category comparison on the second dimension.

Characteristics

Like a bar chart, a side-by-side bar chart also supports both relative and absolute comparisons. It depends on the emphasis of your analysis.

The side-by-side bar chart has the limitation of sidebar numbers. It is difficult to read with a lot of components. Two categories of bars are the best practice. Three should be the upper bound. Four or more bars will be a mess; hard to explore any useful information.

Dataset

In this guide, we continue to use the Titanic dataset. Thanks to Kaggle and encyclopedia-titanica for this dataset.

It contains 887 records of the real Titanic passengers. For more details, please refer to Kaggle.

We will analyze how Parents/Children Aboard affected the survival ratio of passengers.

We have learned about data importing and preprocessing in the bar chart guide. You can refer to it if you need to.

Basic Process

Let's draw a standard side-by-side bar chart, step by step:

  1. Click on Show Me and see the request for the side-by-side bar chart.

    For side-by-side bars, try "1 or more Dimensions" and "1 or more Measures". Requires at least 3 fields.

    This time we don't rely on Show Me. We generate a side-by-side bar chart manually.

  2. Generate an ordinary bar chart first:

    1. Drag "Number of Records" into Rows Shelf.
    2. Drag the "Parents/Children Aboard" and "Survived" into the Columns Shelf.

    basic process 1

  3. Change it into a side-by-side bar chart: drag "Survived" into Marks - Color.

  4. Currently, it is an absolute comparison. Since we want to focus on the survival ratio, we are going to change it into relative comparison.

    basic process 2

    1. Change into ratios: right click "SUM(Number of Records)" in Marks Shelf -> click Quick Table Calculation -> choose Percent of Total.
    2. Change it from table to cell: right click "SUM(Number of Records)" in Marks Shelf -> click Edit Table Calculation -> In Table Calculation panel -> choose Specific Dimensions -> check "Survived" only.
    3. Add percentage label: hold down the Control key (Command key in mac) which will make a copy and drag "SUM(Number of Records)" into Marks - Label.
  5. In the last step, let's polish this chart:

    basic process 3

    1. Rename the sheet title to "Survival Ratios by Parents/Children Aboard" and bold.
    2. Hide the dimensions header: right click header and choose Hide Field Labels for Columns.
    3. Hide the "Number of Records" axis: right click the axis and uncheck the Show Header.
    4. Format percentage label: right click "SUM(Number of Records)" in Marks-Label -> click Format... in the pop-up menu -> In Pane tab -> click Numbers in Default -> choose Percentage -> edit Decimal places to 0.

A basic side-by-side bar chart is now completed.

Analysis:

With the help of a side-by-side bar chart, we can make categorical comparisons across multiple data series, clearly. Passengers with 1-3 parents or children aboard have a higher survival ratio which exceeds 50%.

That is what we have achieved so far. But there are some defects in this basic side-by-side bar chart. We will optimize it with advanced features.

Advanced Features

Add a Reference Line

From the above chart, we are unclear about whether a survival ratio is high or low, relatively. So, we intend to use the average survival ratio as a reference line:

  1. Right-click in the blank of Data Pane -> choose Create Calculate Field...

    reference line 1

  2. Input formula SUM(IF[Survived]==1 THEN 1 ELSE 0 END) / SUM([Number of Records]), and name it "Total Survival Ratio".

  3. Drag "Total Survival Ratio" into Marks - Detail, prepared for the reference line.

  4. Switch to Analytics Pane -> drag Reference Line into Table Mode.

    reference line 2

  5. Edit Reference Line information in the dialog which pops up automatically:

    1. Choose the calculate field which we just created: "AGG(Total Survival Ratio)".
    2. Choose Total computing method.
    3. Display Label in Custom way: <Field Label>: <Value>.
  6. We can see the format functions are limited in the above dialog. So we format the reference line in Format Reference Line Pane by right-clicking and choosing Format...:

    reference line 3

    1. Open Line dialog and select: dashed style, width: 3px, color: red, alpha: 50%.
    2. Open the Font dialog and change font color to red.
    3. Open the Alignment dialog and choose: right and bottom.
    4. Open the Numbers dialog and format: Percentage -> Decimal places: 0.

Show Empty Columns

We noticed that the Survived-Yes bars are missing when parents/children aboard are 4 and 6. It is unbeneficial to the comparison. So, we are going to show the empty columns:

  1. Create two Calculation Fields, similar to the above section:

    Yes: SUM(IF [Survived] = 1 THEN [Number of Records] END) / SUM([Number of Records])

    No: SUM(IF [Survived] = 0 THEN [Number of Records] END) / SUM([Number of Records])

    show empty columns

  2. Drag Measure Names into Filters. And Filter dialog will show up automatically.

  3. Check only "Yes" an "No" in the Filter dialog.

  4. Replace previous "Survived" and "SUM(Number of Records)" with Measure Names and Measure Values.

    1. Drag "Measure Names" into Columns Shelf.
    2. Drag "Measure Values" into Rows Shelf.
    3. Drag "Measure Names" into Marks - Color.
    4. Drag "Measure Values" into Marks - Label.
  5. The last step, let's polish this chart:

    1. Edit Legend Title to "Survived".
    2. Right-click and choose Hide Indicator.
    3. Format percentage labels as the above steps.
    4. Right click the "Measure Values" axis and uncheck the Show Header.

It looks better now. Here is the final chart:

Analysis:

With the help of the reference line, we can explicitly see that Passengers with 1-3 parents or children aboard are 10 to 20 percentage points higher than the total average survival ratio of 39%.

After adding empty columns, the columns are more unified, and we may pay more attention to the empty columns.

Related Charts

The Side-by-side Bar Chart is a variation of the Bar Chart. There are more variations, such as the Stacked Bar Chart, Histogram and Diverging Bar Chart.

Here is a Dashboard of these bar charts for comparison:

Conclusion

In this guide, we have learned about a variation of a bar chart in Tableau - the side-by-side bar chart.

First, we introduced the concept and characteristics of a side-by-side bar chart. Then we learned the standard process to create a side-by-side bar. Next, we enhanced this chart with a reference line and empty columns. In the end, we talked about other variations of the bar chart.

You can download this example workbook Bar Chart and Variations from Tableau Public.

In conclusion, I have drawn a mind map to help you organize and review the knowledge in this guide.

I hope you enjoyed it. If you have any questions, you’re welcome to contact me recnac@foxmail.com.

More Information

If you want to dive deeper into the topic or learn more comprehensively, there are many professional Tableau Training Classes on Pluralsight, such as Tableau Desktop Playbook: Building Common Chart Types.

I made a complete list of my common Tableau charts serial guides, in case you are interested:

CategoriesGuides and Links
Bar ChartBar Chart, Stacked Bar Chart, Side-by-side Bar Chart, Histogram, Diverging Bar Chart
Text TableText Table, Highlight Table, Heat Map, Dot Plot
Line ChartLine Chart, Dual Axis Line Chart, Area Chart, Sparklines, Step Lines and Jump Lines
Standard ChartPie Chart
Derived ChartFunnel Chart, Waffle Chart
Composite ChartLollipop Chart, Dumbbell Chart, Pareto Chart, Donut Chart