Two remedies
- Each dashboard user changes the date range manually every time they open the dashboard.
- The dashboard creator edits the dashboard and sets new defaults for the date range.
Let’s investigate the “Value when workbook opens” function
Then my thought process was like this:
"I want the most recent date in my dataset to be in that parameter when the workbook opens, so if I take MAX([datefield]), that will work!"
Therefore I created a calculated field to do so. But still, I wasn't able to select the "Max Order Date" calculated field to be the current value of the parameter when the workbook opens.
The reason for this is that MAX(datefield) is an aggregation dependent on the filters used in the dashboard or sheet.
The value of it will change if other filters and parameters get changed. This leads to an unpredictable value, and thus we need to fix it so that it's independent of all the other filters.
LOD expressions to the rescue
To overcome this, the FIXED LOD expressions are a perfect fit! Let's change the Max Order Date calculation to be independent of other filters*.
*You might think: "Won't context filters mess up the LOD calculations?". In short: no they won't. The LOD calculations used for filling the parameter's current value are calculated before the worksheets are loaded. So even before context filters are applied. Thus it's safe to use context filters without worrying about impacting the parameters.
{ FIXED : MAX([datefield])}
or even shorter:
{ MAX([datefield]) }
Now, I can select the Max Order Date calculated field as input for the parameter's current value!
So, now every time someone opens this workbook or dashboard, this parameter fills with the most recent date available in the data source.
The next step to replicate the regular date range filter would be to create another parameter which we also prefill with a date upon opening the workbook or dashboard using the same method. This time, we need to create a negative offset from the previously created Max Order Date.
{ FIXED : MAX(DATEADD('month',-3,[Order Date])) }
The final steps to complete the setup
Create a new calculation in which we use both parameters:
[Order Date] >= [Order Date Start]
AND [Order Date] <= [Order Date End]
Drag this to the filters shelf and only select True.
Summary
The only thing you're giving up is the slider handles to change the dates, but that's a small sacrifice to make this date range dynamic based on the underlying data.
Empower your organization with intuitive analytics
Tableau is designed to put the user first because data analysis should be about asking questions and not about learning software. With built-in visual best practices, Tableau enables limitless visual data exploration without interrupting the flow of analysis.
As the market-leading choice for modern business intelligence, the Tableau platform is known for taking any kind of data from almost any system and turning it into actionable insights with speed and ease. It’s as simple as dragging and dropping.
We are a full-stack provider and integrator, relying on extensive experience and best practices to find your unique optimal set-up allowing you to tell the data stories you are eager to tell.