Create Dynamic Custom Date Calculations including defining quarter as trimester of year
1)????Context:
I came across this issue working on the orders data where customer would like to see the orders filtered by last n weeks, last n months etc as well as they would like to see the orders by selecting a start and end date. Currently in Tableau you can only have either last N calculations or start and end date filter. Having both custom date range and last N calculations in the dashboard at user’s discretion makes dashboard flexible to use and get the required insights.
2)????Problem statement:
a.?????Create custom date range parameters: Start date – Last date.
b.?????Create Last N calculations for day, week, month, quarter, year
c.?????Create custom calculations for Quarter defined as a trimester of a year.
3)????Resolution:
a. Here is a snippet of how data looks like,
b.?????Create a parameter: Range or Last N as shown in the image below
b.?????Create second parameter: Unit of Time, it will include all the different time periods that you would like to include for the last N calculations.
c.?????Create third parameter: Range – Start for the user to put the start date.
d.?????Create fourth parameter:?Range – end for the user to put the start date.
e.?????Create fifth parameter: Last N
f.??????Create a calculated field: trimester marker: This is a calculated field to create trimester of a year.
g.?????Create a calculated field: trimester marker max: Here we are trying to get the max of our date field and crea.( in progress)
h.?????Create a calculated field: N_Date_filter_new: This will include all the calculations together and it will go in the sheet as filter where value equals to ‘In’. Please refer to the screenshots below,
In the end, you will be able to filter the data with custom date or last N calculations.