How to Create a Comparison Bar Chart in Tableau

Make a Year-to-Year Comparison for Your Business

Rachel Pemelton
2 min readMay 27, 2020

Tableau is an awesome software tool that can bring all your data visualization dreams to life. While you might not make stunning a stunning ‘viz’ like those found in Tableau Public’s gallery on your first try, with a little know-how you can build an effective viz.

In this post, I’ll show you an overview and video of how to build a chart you can use to compare data segments to the prior year.

Getting Started

For the purposes of this example, I used the superstore sample data that comes with Tableau. This data set contains business data across multiple years, so to isolate data from a specific year I created a new calculated field.

I wanted to view the sales data for a specific year, so I named the new field accordingly and used the calculation ‘IF Year([order date])=2012 THEN [Sales] END’. I created another field for the prior year as well.

Once I have isolated the years I want to view, I can begin building my bar chart. I selected the measure ‘sub-category’ and placed it under Rows, and then placed ‘Sales 2012’ under Columns.

I then placed ‘Sales 2011’ as a detail under Marks. To use this as a visual benchmark, I created a reference line and set the value to Sales 2011. To add another layer to this chart, I created another calculated field using the formula ‘SUM([Sales 2012])- SUM([Sales 2011])’ and added this field as a color under ‘Marks’.

The resulting chart provides an easy way to see how each subcategory’s sales performed in relation to prior year sales. Watch the video below for a full breakdown.

--

--

Rachel Pemelton

Currently participating in the Praxis program. Always seeking to learn and improve myself.