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.
- After connecting to the dataset in Tableau, drag the Raised measure into the Columns shelf.
- Next, drag the Spent measure into the Raised axis.
- Tableau automatically creates the Measure Values and Measure Names fields along with the Measure Values card that lists all our measures.
- Next, Drag Measure Names onto the Color section of the Marks card. This assigns different colors to our measures.
- Drag State into the Rows shelf and sort it in descending order by Measure Values.
- Next, we need a measure to look at our difference so, we will need to duplicate the Spent measure.
- After creating a duplicate measure, drag Spent(copy) into the Columns shelf next to Measure Values. Right-click and select Dual Axis.
- Tableau changes the chart’s appearance to a circle, so we need to change it back to a bar chart.
- Select the Gantt Bar option in the SUM(Spent (copy)) Marks card.
- Remove the Measure Names field from Color.
- Create a calculated field named Raised > Spent (with the formula below) and drag it onto Color.
- Create another calculated field named Difference (with the formula below) and drag it onto Size.
- Create a calculated field named %Difference (with the formula below) and drag it onto Label.
- 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.
- 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>