Is it possible to limit the range of selectable dates in the date filter widget in any way?

Hi,

Is there any way to limit the range of dates that a date filter widget in a dashboard allows to be selected? I'm using an embedded Metabase dashboard in a project where it would be very important to be able to limit the selectable date range to prevent the end user from accidentally seeing incorrect reports (due to selecting a time window that extends outside the period for which we have all the required data available).

I currently have 2 date filters (using the month and year widget) to define the start and end of the shown reporting period and I have connected these to field filter variables in the SQL statements. The issue is that I haven't found any way to limit the values that can be selected using these filter widgets.

The date widget doesn't seem to care at all about the value range in the underlying column it is linked to (which is pretty understandable). I have also tried creating a separate date range filter and setting it as a linked filter to limit the values of the 2 other date filters, but it has no effect on the two widgets it is supposed to be limiting. This seems to me like a bug/missing feature, as you would intuitively expect the linked date range filter to work for limiting selectable dates in other date filters. (Also the whole current concept of linked filter seems somewhat confusing and broken or at least very limited when it comes to date filters, but that is another issue).

Does anyone know of any other way to limit the ranges of dates selectable in the date filter widget? I've browsed through the docs and tried searching for answers to this for a while now, but nothing seems to come up. Or let me know if I'm just doing something clearly wrong with the linked date filters.

Hi @antti
Since you're doing this in SQL, then you would be able to write the limit in the where-clause, so it would never allow selecting outside some specific period.
But there's currently no limit in the widget for the user.
Since you're using embedding, then it's possible for you to have the filters outside Metabase in your own code and handle selection there and just send the filter values to Metabase.

Thanks for the quick reply!

Ok, good to know. I guess we'll probably have to go with implementing the date range selection within the application UI that embeds the Metabase dashboard. Was hoping to avoid that as it easily gets clumsy in terms of UX and adds extra work, but oh well.

Are you aware of any plans to add that possibility of limiting for the date widget or to make improvements to how the linked filters function for dates? I could see them saving time also for other users, so I could open an issue on github if nothing like it is already planned. Just to keep it in mind as a possible improvement in the future.

Thanks again

@antti There were talks about changing/updating the date widget component to allow more flexibility (which doesn't support limits as far as I can see), but also fix issues like this, though it's not on any near-term roadmap sadly:
https://github.com/metabase/metabase/issues/4585

Ok, thanks. I think I'll create a separate github issue for the linked date filter functionality stuff with a more detailed description later this week after having a look for any other related issues. The intuitive and more useful functioning of linked date filters would require the change/update to the date picker widget as a prerequisite and sets some extra requirements for the new component, so it is closely related to it, but at the same time also a separate functionality issue on its own.