Hi john white!
You are correct - you can look to use a parameter where the user can first select from here: Most Recent or Custom, and after click Custom they can then use a Date Picker.
I first find the Max Date in the data using a LOD expression. If they select Most Recent, I use this field, otherwise I use the Date Picker (which I compared to Max Date to ensure it's not more recent than the max date - if so, I "snap" it back to the Max Date.
I've attached an old date template workbook for reference. I'm sure I've learned new/better ways since doing this, but figured it might help!
DateFunctionsTemplate.twbx 56.2 KB
Bryce, Thank you this is a solution but would not fit quite what i am looking for due to the fact my clients like to be able to still have the ability to fully customize their data and not have it set on the most current looking back. For example, they may still only want to see 2 months ago data and nothing else. This did spark my interest and I came up with a solution to use the current month and parameters together
The below will allow the user to select whatever date they want to use to get the current month whether their data is today () -1 or any lag. This calculation tells the tableau based on the selection which calculation to use and whether to activate the parameters or not. When Current Month is selected, the parameters are not active and only when the custom is selected they become active.
IF [Date Selection] = 'CM' THEN
IF [Date]>=DATETRUNC('month',today()-1) and [Date]<Today()
THEN 'True' END
ELSEIF [Date Selection] = 'Custom' THEN
IF [Date]>= [Start Date] AND [Date]<= [End Date]
Thanks Bryce for putting together solid logic to build on. Hope this helps if you want to use this also.
1 of 1 people found this helpful
Glad to hear it!
Might add one suggestion that is to make the date filter just be a boolean rather than returning a string - this coulD help slightly improve performance. All the best!
That is a great suggestion and i honestly did not think i could do it that way. Thanks again