I am trying to prevent users from entering improper date ranges.
I have used a context filter to create the allowable date range (for example all dates in 2023), and a context-based date filter from which viewers can modify the ranges.
As long as viewers use the slider to set the dates of the report, this works fine and there is no way for them to choose a date outside of the context dates.
The problem comes when naughty viewers use the Date Entry/Calendar function to select values that we don't want them to use-- for example an end date of 6/22/2024 (outside of 2023).
I could remove the readouts completely, but our viewers want the three options:
- Date entry by slider
- Date entry by keyboard
- Date entry by calendar
Can the user-entered value be read and used in a calculation so as to create an alert indicating they've entered an incompatible period? In this example I've not been able to write code that says "the maximum date range is 6/22/2024."
Can the date filter be made more "draconian" so as not to allow naughty dates? For example, I can create a parameter of just allowed values, set it to Type In, and it won't allow me to use bad dates. This doesn't include a nice sliding range, though.
Should I strive to make a Frankenstein's monster of comparative cross-populating parameters and filters? (I'm getting dizzy just thinking about it)
Is there a simple solution?
Michael Hesser (Tableau Forum Ambassador)
Hi @Michael Hesser
I'll chip in on this with what I can think of - probably not what you want to hear though, and hopefully someone else will have some better ideas!
First thing I thought was that you're spot on, and the only real way to build what you want is a mash up of various things and/or a custom view with dashboard actions. Quite a lot of work though to build the slider, parameter for type in, and a date picker!
Second thought was that perhaps the most expedient thing to suggest to the client is that Tableau is already telling them they've picked an invalid date (the line on the slider is a lighter grey showing that the value is out of range)
Maybe you could have a text box on the dashboard just below this saying "only dates within the allowable range will apply, grey bar indicates dates outside of allowable range" (or something like that). It does indeed look like Tableau doesn't actually allow the underlying data to be out of the range ... which is why we can't do anything in a calc to detect the situation. Although maybe if it was a table calc filter you could do some detection...
My next thought was whether set controls could help. They can in that you can get two out of the three things you want (with a set control you seem to be able to have type in and slide). However I think you'll need two sets. And detecting when start date is after end date doesn't look that do-able (as everything is filtered out so no marks and hence no message can be displayed).
For this I needed to set the set controls to only show values in context (can't do relevant values for set controls I think). And then customise to slider and to remove the all option. Workbook attached in case it's helpful.
Ta, Steve