For the Back to Viz Basics (#B2VB) teaser challenge in December, we looked at survey data relating to what food people eat on Thanksgiving in the United States. The challenge was to create ‘your best bar chart’. For my viz, I came up with this simple bar chart with a process bar:

View on Tableau Public

I wouldn’t say this is my best bar chart by any means, but I went for something simple, clean, and a little different to what I would usually build. I was reminded of this chart type when I saw Kevin Flerlage present a version of it in his “Make It Better” talk with Ken Flerlage at TC21. I highly recommend watching their talk, if you missed it.

This bar chart has a thin progress bar that runs through the middle of each bar, through to 100% or in other words, the maximum possible value. While not necessary with this data set, this technique can be useful if you are tracking the completion or performance of metrics, versus a defined target. From a design perspective, it also creates a more clean, square chart than a regular bar chart would, since the thin progress bars all end at the same point.

Let’s explore how you can build one of these charts yourself.

There are two approaches to building this type of chart, depending on if you want to use the progress bar to compare all bars to the maximum value (the longest bar), or if you want to compare all bars to a target (i.e. 100%). We’ll start with the approach shown above which compares all bars to a target.

Approach 1: Comparison to 100% Target

This approach works well if you are tracking the completion of something through to 100%. Note, in this example, we’ll be working with percentages, using the data from the Thanksgiving survey shared for the #B2VB December challenge.

For each step, I’ve included a GIF to help you to understand the step-by-step process in Tableau.

Step 1: Build a Bar Chart

Open a new worksheet and build a horizontal bar chart as you normally would:

For this step, I…

  • Opened a new worksheet
  • Dragged my measure (SUM(Percent)) to my columns shelf
  • Dragged my dimension (Food) to the rows shelf
  • Sorted the bars in descending order, so the longest bar/food with the highest percentage is shown at the top
  • Hid the row field labels by right-clicking on the “Food” field label at the top of my axis labels and selecting “Hide Field Labels for Rows”.

The last two steps are optional, but in my opinion, create a bar chart that is cleaner and easier to read.

Step 2: Create a Placeholder Calculation

Next, we are going to create a placeholder calculation that we’ll later use for our secondary axis. To do this, we’ll write a new calculation directly in the columns shelf.

For this step:

  1. Double-click on the white space on the columns shelf, to the right of the green measure pill
  2. Write a new calculation directly on the columns shelf: MIN(1)
  3. This will create a new measure pill. Click the pill and open the formatting options to format this new measure as a percentage.

By creating a placeholder calculation, Tableau gives us another Marks Card to work with. This gives us more flexibility and the ability to use multiple mark types or styles in the same chart.

At the moment, we have two separate charts; our original bar chart on the left, and another bar chart to the right which shows a bar for each food type, each of the same length. Later we’ll combine these but first, let’s apply some formatting.

Step 3: Format the Progress Bars

Next, we’ll going to format of the bars so we have two distinct styles.

We’re going to want to adjust the style of the bar chart on the right so we’ll click and expand the Marks Card named “AGG(MIN(1))” to access the Marks Card options for this chart.

These bars will become our thin progress bars so we want to format them so they are very narrow and shaded grey.

To do this:

  • Click the “Colour” shelf on the Marks Card and select a mid-grey colour of your choice from the palette to re-colour the bars.
  • Click the “Size” shelf on the Marks Card and reduce the size down as far as it will go using the slider to reduce the width of the bars.

I wanted my bars narrower than possible using the size options so I returned to the “Colour” menu and added a white border to my bars to make them appear even narrower. This step is optional.

Step 4: Create a Dual-Axis Chart

Now we want to combine both of these charts together onto a single chart. We’ll do this by creating a dual-axis.

To do this:

  • Click on the “AGG(MIN(1))” pill on the columns shelf and select “Dual Axis” from the menu.
  • Tip: Adjust the mark type from “Automatic” to “Bar” on the “All” Marks Card before completing this step to avoid your marks changing from bars to circles. If they do change to circles, simply adjust the mark type on each Mark Card to “Bar” using the drop-down menu.
  • Right-click on the secondary axis (the one at the top of the chart) and select “Synchronise Axis” to ensure each axis is in sync with the other.
  • Right-click on the secondary axis again and select “Move marks to back” to ensure the progress bars are displayed behind the main bars in your chart. If the progress bars are already shown behind the main categorical bars in your chart, you don’t need to complete this step.
  • Right-click on the secondary axis one last time and de-select “Show Header” to hide the secondary axis.

We’re almost there! We now have a single chart with 100% progress bars.

Step 5: Apply Formatting & Add Labels

Finally, we want to add some labels to the ends of the progress bars:

To do this:

  • Using the “AGG(MIN(1))” Marks Card, drag your measure to the Labels shelf. This will add a label to the end of the progress bars, displaying the current percentage for each bar.
  • Right-click on the axis at the bottom of the chart and de-select “Show Header”. Since we are showing the values against each bar, the axis is no longer necessary.

And lastly, we’ll format the chart:

  • Remove any gridlines and borders.
  • Show the zero line on the y-axis as a solid grey line (instead of dotted). This give the bars something to rest on, rather than floating in mid-air.
  • Adjust the tooltips and bar colours, as desired.

And you’re done!

Approach 2: Comparison to the Maximum Value

Example of a progress bar chart with a comparison to the maximum value.

As mentioned at the beginning of this post, if you want to use the progress bar technique to compare all bars to the maximum value (the longest bar), you’ll need to take a slightly different approach.

The technique is the same as the approach shown above, except for step 2. Instead of creating a placeholder calculation, you’ll need to create a new calculated field to calculate the maximum value in your chart (in other words, the value represented by the longest bar) and you’ll use this for your progress bars.

For this example, I’m using the Superstore Sales dataset and we’ll be looking at sales by sub-category.

Here’s how to do it:

  • Create a new bar chart by dragging the “Sales” measure to the Columns shelf (using the SUM aggregation) and dragging the “Sub-Category” dimension to the Rows shelf.
  • Create a new calculated field called “Window Max Sales”. The calculation is: WINDOW_MAX(SUM([Sales]))
  • This calculates the maximum sales value in the given view (in this case, our bar chart). The maximum sales value should return the same value as the longest bar in the bar chart. This will act as our comparison point for the progress bars.
  • Drag the new “Window Max Sales” calculated field to the Columns shelf, to the right of the “SUM(Sales)” pill.

From here, the steps are the same as those listed above. Instead of using the “AGG(MIN(1))” placeholder referenced in the tutorial, you’ll use the “Window Max Sales” measure on your secondary axis, and in any subsequent steps which reference the placeholder.

I hope you found this tutorial useful and you’re able to apply this technique in your own work.

Thanks for reading!