3/16/2019
The way to Construct an Overlapping Bar Chart in Tableau
There continues to be sturdy curiosity in my current visualization, Bar Hopping: Theme and Variations on a Bar Chart. This week on LinkedIn, Steve Adams saw the post and asked about building another variation of a bar chart in Tableau. He was fighting making an attempt to breed overlapping bars. Usually, I’d recommend we keep away from a majority of these visualizations. Overlapping bars could make the comparisons more durable to see and a bar with a goal line could be a significantly better alternative. Nonetheless, this visualization is seemingly a requirement to be compliant with the Worldwide Enterprise Communication Requirements (IBCS), so it’s crucial for Steve to have the ability to reproduce this in Tableau.
Right here is an instance of the visualization that he wished to breed.
Step 1: Information Construction
The information set right here is fairly simple. Nonetheless, the construction of the info is essential. You’ll discover there’s a sort area that reveals the precise and price range after which a separate area for the Revenue %.
Here’s a have a look at the info. You may download the data here to observe together with these directions.
In case your information is structured with every worth as a separate area then you will want to pivot the info to this format.
Step 2: Construct the Viz
Steve talked about in his publish on LinkedIn that plotting the triangle wasn’t crucial, so we’ll take care of that later. For now we’ll simply filter the triangle information out.
Drag Sort to Filter, uncheck Triangle and click on OK.
The trick for this resolution is to construct a calculated area to offset the date based mostly on the sort.
Calculated Discipline: Date Offset
Method:
if [Type] = ‘Precise’ or [Type] = ‘Forecast’ then [Date] + 15
else [Date] + 10
finish
Discover that the date is about on the 1st of the month within the information. This system offsets the date based mostly on the kind. If it is the Precise or Forecast, the bar within the entrance, then it provides 15 to the date, and for the bar within the again it solely provides 12.
Proper-click and drag Date Offset to Columns and choose the very high choice, Date Offset (Steady). This can place a precise date as a steady date (Inexperienced tablet date) on the x-axis.
Double-click Revenue % or drag it to Rows.
Change the Mark Sort to Bar within the drop down menu on the Marks Card.
Drag Sort to Shade.
Double-click the colour legend to vary the colours of the bar chart. Darkish grey for Precise (#5c6068), gentle grey (#d3d3d3) for Forecast and white for Funds (#ffffff).
On the colour legend, drag Forecast above Funds to carry the Forecast bar on high of the Funds bar.
Choose Shade on the Marks Card and set the border shade to black.
Choose Measurement on the Marks Card and choose Mounted and enter a price of 8 or 10 (or desired width) for the « Width in Axis Items ».
Double-click on the x-axis and choose the Tick Marks menu. Change the Main Tick Marks to Mounted in 1 « Months » models. You need to use the date to heart the date.
Proper-click on Date Offset on the Columns and choose Format. Change the Date format below Scale to Customized and enter mmm. This can change the format of the date to « Jan ». Format the font as desired.
It’s best to now have a bar chart that appears one thing like this
Step 2: Construct the Viz
Now that we have constructed the viz, let’s end by including the triangle. To do that, create two extra fields. One for the Revenue % with out the triangle information and that’s solely the Revenue % for the triangle.
Calculated Discipline: Revenue % with out Triangle
Method:
if [Type] = ‘Triangle’ then NULL else [Profit %] END
Calculated Discipline: Revenue % for Triangle
Method:
if [Type] = ‘Triangle’ then [Profit %] else NULL finish
Now now we have two fields, one which have the Revenue % for the Precise, Funds and Forecast and one other area for the Revenue % for Triangle.
Take away Sort from Filters
Take away Revenue % from Rows
Double-click Revenue % with out Triangle or drag it to Rows.
Choose Measurement on the Marks Card and choose Mounted and enter a price of 8 or 10 (or desired width) for the « Width in Axis Items ».
On the colour legend, drag Forecast above Funds to carry the Forecast bar on high of the Funds bar.
Double-click Revenue % for Triangle or drag it to Rows.
Change the Mark Sort to Form within the drop down menu on the Final Marks Card (the one for Revenue % for Triangle.
Click on Form on the identical Marks Card and choose the stuffed in triangle that’s pointing to the proper.
Click on Measurement on the identical Marks Card and make the dimensions larger to match the unique.
Take away Sort from the identical Marks Card that’s on Shade.
Proper-click on Revenue % for Triangle on the Rows and choose Twin Axis.
Proper-click on the secondary y-axis and choose Syronize Axis.
Proper-click on the secondary y-axis and uncheck Present Header.
Proper-click on the Null Indicator within the backside right-hand nook and choose Disguise Indicator.
Double-click the colour legend for Triangle and alter the colour to a grey to match the colour of the triangle form.
The ultimate chart ought to appear like this. Be happy to obtain my Tableau Workbook under.