ad

Three Methods for Building a Bar in Bar Chart

Contributor & Author: Tiffany Spaulding
Reference: Click Here

Many users in the Tableau community depend on the “Show Me” menu to get them started down the path toward their goal visualization, however all too often “Show Me” provides something other than what you envisioned. “Show Me” is a wonderful way to enable new users in the tool to gain momentum, but I challenge you to think with the tool instead of guessing where it will end up.

A quick reminder as we dive in, the Columns and Rows shelves are what I term “Structural Shelves.” They determine orientation or position of headers, footers, and axes. Continuous fields (represented by green pills in view) will generate an axis when landed to a structural shelf. Discrete fields (represented by blue pills in view) will generate headers, footers, or buckets when landed to a structural shelf. They partition the data in view.

To assist with clarity of the instructions provided, italicized text denotes a specific mouse control while bold text denotes either a field or menu selection.

This week’s challenge: What are the possible methods to build a Bar in Bar chart? Let’s take a look at Sales versus Budget Sales in the Sample Coffee Chain data set.

Method # 1: Measure Names Measure Values (MNMV)

  1. Double click Product Type (loads to Rows shelf).
  2. Double click Product (loads to Rows shelf).
  3. Drag & drop Sales to Columns.
  4. For ease of viewing, I recommend expanding your view to fill the available space by adjusting the Fit (dropdown arrow next to "Normal" in the top toolbar) to "Entire View."
  5. Adjust the thickness of the bars to make them thinner by clicking the Size button on the Marks Card and shifting the slider to the left until it is at the tick mark.
  6. Drag & drop Budget Sales to the axis built by Sales at the bottom of the view. Measure Names Measure Values will automatically be triggered to view. Notice the axis title is now “Value” instead of Sales.
  7. Right click on the axis and select Edit Axis. In the title box, delete Value and replace it with “USD”.
  8. Move Measure Names from the Rows shelf to Color on the Marks Card.
  9. From the data window, drag & drop another instance of Measure Names to Size on the Marks Card.
  10. To unstack the marks, select Analysis > Stack Marks > Off in the top menu.

  11. Tableau defaults to loading the two fields in alphabetical order from thin to thick and front to back. To make Budget Sales the background or referenced field and Sales the dominant field, pick up Budget Sales from the Measure Names size legend and drag it beneath Sales. This reassigns which measure is thin and which is thick.
  12. Click the Color button on the marks card and select Edit Colors. Set Sales to blue and Budget Sales to gray.
  13. Depending on the colors selected, color deficient viewers may struggle to clearly see the difference between the two colors. For assistance, add a white border to the bars to define the edges by selecting the Color button from the Marks Card, and using the drop down menu for border to select white.
  14. Depending on the number of rows shown in view, the size proportions may need to be adjusted to suit your needs. To do so, right click on the size legend and select Edit Sizes.
Method # 2: Dual Axis Bar Chart
  1. Double click Product Type (loads to Rows shelf).
  2. Double click Product (loads to Rows shelf).
  3. Drag & drop Sales to Column.
  4. For ease of viewing, I recommend expanding your view to fill the available space by adjusting the Fit (dropdown arrow next to "Normal" in the top toolbar) to "Entire View."
  5. Load Budget Sales to the Columns shelf. Notice you now have 3 marks cards (the All marks card which is the one we always have, a marks card just for SUM (Sales), and a marks card just for SUM (Budget Sales). We will come back to these in step 7.
  6. Right click Budget Sales on the Columns shelf and select Dual Axis
  7. Tableau changes the automatic mark type from bars to circles. Don’t freak out, let’s change them back to bars. Ensure you are on the All marks card (All should be bold. If it isn’t click the word All until it becomes bold and the marks card appears beneath it). From the All marks card, use the drop down arrow next to the word Automatic to change the mark type to Bar. This will change the mark type associated with SUM (Sales) as well as SUM (Budget Sales). If only one mark type changed in view so you have bars and circles, you were not on the All marks card.
  8. By default on a dual axis chart, each axis maintains independent scaling. In our case, the unit of measure is the same and the quantities are proportional, therefore it is best practice to synchronize the scale of the two axes. Right click on the top axis for Budget Sales and select Synchronize Axis.
  9. With the axes synchronized, we do not need to show both axes. Right click on the top axis for Sales and uncheck Show Header (if you ever need it back and using CTRL+Z would undo far too much work, remember that axes are generated by green fields located on a structural shelf; right click on SUM (Sales) on Columns and select Show Header if you need to bring the axis back).
  10. The remaining axis no longer only represents Budget Sales. Right click on the bottom axis and select Edit Axis. Change the title of the axis to “USD”.
  11. Tableau has defaulted the layering of the marks from front to back based on the order of the measures loaded to the Columns shelf. To place Budget Sales as the background bar, switch the order of the two measures on Columns to read SUM (Budget Sales) and then SUM (Sales).
  12. To make the foreground bar thinner, select any one of the Sales bars to bring the SUM (Sales) marks card forward. From the marks card, click the Size button and move the slider to the left to the desired thickness.
  13. To add a border, from the SUM (Sales) marks card, select the Color button and use the dropdown for border to select white.
Method # 3: Bar Chart with Reference Line
  1. Double click Product Type (loads to Rows shelf).
  2. Double click Product (loads to Rows shelf).
  3. Drag & drop Sales to Columns.
  4. For ease of viewing, I recommend expanding your view to fill the available space by adjusting the Fit (dropdown arrow next to "Normal" in the top toolbar) to "Entire View."
  5. Adjust the thickness of the bars to make them thinner by clicking the Size button on the Marks Card and shifting the slider to the left until it is at the tick mark.
  6. To show Budget Sales as a reference line, we must load it into the temp table first. To do so, drag & drop an instance of Budget Sales to Detail on the marks card. Nothing will change in view but now we can call against the values to generate our reference lines.
  7. Right click on the Sales axis and select Add Reference Line. 
  8. In the pop up menu, keep the setting of a Line. 
  9. Change the Scope to Per Cell.
  10. Value should be SUM (Budget Sales).
  11. Label should be None.
  12. Format the Reference line to be a none with gray fill below. Click OK.
  13. Add a white border to the bars (Color button > Border > White).
  14. To add a white line in between every row, right click in the background white space of the bar chart and select Format.
  15. The format menu will overtake the data window. At the top are 5 buttons. Currently the menu is inside the Format Font menu which is the first button. Click the 4th button from the left to enter the Format Borders menu.
  16. Under Row Divider, change Pane to be a white semi-thick solid line. There is now a white line between every Pane.
  17. To place a white line between every Cell, adjust the Level slider to the right.
Depending on the structure of your data set or the custom formatting needed for your visualization, it might be easier to build through one method instead of another. My personal go-to is the dual axis method because the additional marks cards give greater power over formatting and labels. 
Bar in Bar charts allow for quick and accurate comparison across measures, letting your eye visually compare two metrics relative to each other without requiring much explanation or taking up more dashboard real estate. They are very useful to display Budget to Actual as in the examples provided here, but can be used for Year over Year comparisons. While it is possible to technically produce a “Bar in Bar in Bar…” chart in Tableau by landing a discrete field to Size on the marks card, I recommend only using two layers of bars. When in doubt, follow the KISS rule (Keep It Simple Sweetheart). Should you need to show Budget, Actual, and Forecast on the same viz, consider utilizing a Bar in Bar chart for Budget to Actual, then add a reference line to show Forecast.