We know that a bar chart is used to compare data across categories, but have you ever wondered how to quickly look at the difference between two bar charts?

During one of our client project weeks, our coach suggested using a Gantt bar to look at the difference between two charts. This tip was very useful, and I thought it would be helpful for everyone. Therefore, in this blog post, we will revisit the #MakeoverMonday challenge – Fundraising by Members of the 117th Congress | Kaggle using the data from the 2022 election cycle fundraising dataset.

 

  1. After connecting to the dataset in Tableau, drag the Raised measure into the Columns shelf.
  2. Next, drag the Spent measure into the Raised axis.
  3.  Tableau automatically creates the Measure Values and Measure Names fields along with the Measure Values card that lists all our measures.
  4. Next, Drag Measure Names onto the Color section of the Marks card. This assigns different colors to our measures.
  5. Drag State into the Rows shelf and sort it in descending order by Measure Values.
  6. Next, we need a measure to look at our difference so, we will need to duplicate the Spent measure.
  7. After creating a duplicate measure, drag Spent(copy) into the Columns shelf next to Measure Values. Right-click and select Dual Axis.
  8. Tableau changes the chart’s appearance to a circle, so we need to change it back to a bar chart.
  9. Select the Gantt Bar option in the SUM(Spent (copy)) Marks card.
  10. Remove the Measure Names field from Color.
  11. Create a calculated field named Raised > Spent (with the formula below) and drag it onto Color.
  12. Create another calculated field named Difference (with the formula below) and drag it onto Size.
  13. Create a calculated field named %Difference (with the formula below) and drag it onto Label.
  14. We can now view the difference. You can update the number format for the %Difference measure using a custom format such as +0%;-0%;0%. Right click on the Measure labels and hide the header.
  15. After formatting the lines and borders, we have our final output.

    Thanks for reading this blog, I hope it was helpful to you!

 

Icon attribute: <a href="https://storyset.com/data">Data illustrations by Storyset</a>
The Data School
Author: The Data School