In the short article 10 Data Viz Tips i Learned native Google Analytics, I mutual that prior to I began using Tableau, I began my job in digital analytics making use of Google Analytics. One of the attributes I utilize many in my analysis work in Google analysis is the capacity to compare the performance during any date selection to the performance throughout an same date variety immediately preceding it. Because that example, if I select a date variety of 10 days, ns would choose to see the performance of those 10 days and also the 10 work that came before my selected range. In Google Analytics, this is the first option if you choose a comparison date range, yet it is tricky in Tableau.
You are watching: 1. what would you use to compare two date ranges in a report?
I have actually seen a equipment to this that uses an axis of variety of days, however we have a brand-new solution the leverages a date equalizer calculation come compare any date variety to the identical prior duration on the same date axis – a much friendlier user experience!
How come Compare any kind of Date selection to previous Date range on exact same Axis in Tableau
Step 1 – develop Parameters for day Range
Build two different parameters through a data form of “Date”; one will certainly be the minimum end of her range, and also the various other will be because that the maximum end of your range. Once these are created, right-click on each one and choose “Show Parameter Control”. If you would favor to follow along making use of the Sample Superstore data resource that comes v every download of Tableau, the check out looks choose this in ~ this point:
Step 2 – develop a Calculated ar for job in Range
Create a calculated field that provides the DATEDIFF duty to calculate the variety of days in the selected range. In this tutorial, we room using a granularity that day, so us will want to include a “+1” to ensure we record the present day. The calculated ar looks like this:
Note the if you desire to spot inspect that her formula is working correctly and also calculating the correct answer, add this calculated ar to her view through an aggregation the average. By default, the aggregation will certainly be amount so the calculated ar will take it the variety of days multiply by the number of records (which is no what we want).
Also keep in mind that the Minimum date parameter is first in our calculation. If you carry out this backwards, girlfriend will obtain the dorn result.
Step 3 – develop Boolean Calculated areas for Current period and prior Period
The last step in the set-up process is to create two calculated fields: One which will certainly limit the dates to the existing period, and also one which will certainly limit the date to the duration immediately coming before the range selected in the parameters indigenous above.
Calculated field for present Period
Calculated field for prior Period
Note: The date logic offered to produce these Boolean calculations can have instead been nested within the calculations in the complying with steps but I like to leave them as their own fields in my data.
Step 4 – develop a date Equalizer
The date equalizer is a calculated field that will placed both the date selection selected and the date range immediately preceding the selection on a solitary axis! The formula is:
Step 5 – develop Calculated areas for your Measure
We are currently ready to use the special day fields we set up prior to to develop the measures that will be provided on ours view. For this come work, friend will need to set up a calculated measure up that mirrors the power for the existing period, and a 2nd calculated measure up that reflects the power for the front period. Ns am walk to use Sales as my measure, but this same approach works for any kind of measure without having to replicate the an initial four steps. Right here are my two calculated measures for Sales:
Prior period SalesSUM(IF
Step 6 – produce the View
If you space wanting to produce a constant line graph comparing the performance of a measure to the selected date range and the date range immediately coming before it top top the very same axis:Place the newly developed Date Equalizer measurement onto the Columns shelf through an aggregation of consistent dayPlace the newly created Current duration Sales measure on the Rows shelfDrag the newly produced Prior period Sales measure up onto the very same axis together Current duration Sales – you could additionally create a dual-axis v one measure on each, yet this would require you come synchronize the axes; a action that is unnecessary since these two procedures should be an apples come apples to compare on the very same y-axis.
See more: Yes Let The Hate Flow Through You Gif S, Let The Hate Flow Through You Gifs
My last product looks favor this:
You deserve to now select any type of date variety you want and have Tableau present the performance during the current period to the prior period immediately coming before it – on the same date axis!Once you’ve obtained the structure down, try using parameters come change which metric is gift graphed or change the day aggregation that the day equalizer.