Chapter 70. How to Compare Unequal Date Ranges on One Axis

In the previous chapter, I shared a technique for comparing any date range in Tableau to the equal date range that immediately preceded the selection. But what do you do if you want to pick both ranges, even if they aren’t right next to each other on the calendar? What if one range has a different number of days than the other?

This chapter shows how to compare the performance during any two date ranges on one axis, even if the selected date ranges have unequal durations.

First, create four separate parameters with a data type of Date:

  • Range 1 Minimum Date

  • Range 1 Maximum Date

  • Range 2 Minimum Date

  • Range 2 Maximum Date

To start the view, show all four parameter controls by right-clicking on them and choosing “Show parameter control.” This allows the end user to choose the two date ranges. For the purposes of this illustration, I will compare 10/1/2015–10/11/2015 to 9/8/2015–9/27/2015. Notice that not only are these date ranges disconnected (there are three days skipped between them), but the first range is 11 days while the comparison range is 20 days:

prta 7001

Next, set up a calculated field that classifies whether the date falls into Range 1 or Range 2. If you are following along using the Sample – Superstore dataset, the formula looks like this when using Order Date as the date dimension:

IF [Order Date] >= [Range ...

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.