Measuring a department or entire organisation's progress towards a goal is something that will always be a common use case in Tableau.
A clean and effective way to visually show this is using a variation of everyone's favourite tool - the bar chart. However, adding in some details which can show 2 measures in one chart can allow for easy comparison for current progress towards a specified target e.g.:
- current year sales vs previous year sales.
The easiest way to do this is to use a dual axis chart combining a bar chart with a gantt bar using the bar chart to show current year sales and the gantt bar to show previous year sales.
The below example uses the Tableau Sample Superstore Dataset:
First we need to calculate the sales for the current year (2021 at the time of this post) and the previous year (2020)
This can be done by creating two calculated fields, one for each year:
Use the year of order date to return an integer for only 2020, then multiply this integer by sales (all other years will = 0). This returns the sales for only 2020, the same calculation can be repeated substituting 2021 for 2020 to return current year sales.
For this example we will look at sales by month so right click and drag order date to the columns and select discrete months (the blue month option).
Then place 2021 sales onto the rows - change the mark type to bar chart and you will have a bar chart showing the sum of 2021 sales over the 12 month period.
To get the previous year (2020) sales on the same chart, drag the '2020 sales' field onto the right hand edge of the bar chart until you see the green ruler icon to create a dual axis chart.
You can then right click on either axis and click 'Synchronise Axis' and you will have a bar chart with both current and previous year sales on it.
Now we will need to make each year easy to compare against the other, the first step is to go to your second marks card (the one for previous year sales) and change the mark type from a 'Bar' to a 'Gantt Bar'.
You should now have the current and previous year clearly distiguished from each other with the two seperate mark types - changing the colour of the gantt bars to black can make this look much cleaner.
The final step is to colour the bars for the current year as to whether they are below or above the previous year gantt bar. In order to do this you have to create another calculated field:
This field will just return a true or false value based on whether the current year sales (2021) are above or below the previous year sales (2020).
To apply this, go to the marks card for 2021 sales, take measure names off of the colour shelf and replace it with your new calculated field. The bars should now be coloured relative to whether they are above or below the gantt bars.
You can then edit the colours based on what you want to highlight e.g. Red for months that were below the previous year sales, Grey for months that are above.
The final chart should look something like this:
It's a pretty simple chart which allows for pretty easy comparison of the current progress towards a goal with a clear visual indicator to show whether the goal has been met.