Chapter 69. How to Compare Two Date Ranges on One Axis
In Chapter 51, I shared that before I started using Tableau, I began my career in digital analytics using Google Analytics. One of the features I utilize most in my analysis work in Google Analytics is the ability to compare the performance during any date range to the performance during an equal date range immediately preceding it. For example, if I choose a date range of 10 days, I would like to see the performance of those 10 days as well as the 10 days that preceded my selected range. In Google Analytics, this is the first option if you choose a comparison date range, but it is tricky in Tableau.
I have seen a solution to this that uses an axis of number of days, but this solution leverages a date equalizer calculation to compare any date range to the equivalent prior period on the same date axis—a much friendlier user experience! There’s an example of this experience in my Tableau Public visualization, Super Sample Superstore.
How to Compare Any Date Range to the Previous Date Range on the Same Axis in Tableau
If you ever need to equalize dates to compare two ranges on the same axis, follow these steps:
-
Create parameters for date range.
Build two separate parameters with a data type of “Date”; one will be the minimum end of your range, and the other will be for the maximum end of your range. Once these are created, right-click each one and choose Show Parameter Control. If you would like to follow along using Sample ...
Get Practical Tableau now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.