Replies: 2 comments 14 replies
-
Is there any update on this topic? We also tried to get the values of time range filter using The problem we are facing is the following: It would be nicer if :
More generally, why is the time range filter different from the other filters? |
Beta Was this translation helpful? Give feedback.
-
I am also facing the same issue in version 1.0.0 . It was working in prior versions but is broken now. Here's the function I have defined in superset_config.py .
|
Beta Was this translation helpful? Give feedback.
-
Is there a way to pass
[from, to]
date filters to an SQL query?I've been looking everywhere in documentation and source code and haven't found a solution to passing date filters to custom SQL queries. I'm working on some advanced multi-join aggregations from existing tables/views.
As a very simple example of the issue I'm trying solve, consider this SQL query:
I'd like to be able to access the date filters that are propagated through a
Filter Box
widget. in a dashboard. I've found that the values of these filters are available as these variables (thanks to https://superset.incubator.apache.org/faq.html#how-to-add-dynamic-filters-to-a-dashboard): https://github.com/apache/incubator-superset/blob/40776bd547166b6975574e815ec02add04781248/superset/assets/src/visualizations/FilterBox/FilterBox.jsx#L38-L44With that in mind, I could make use of
__time_range
inside my SQL filter viafilter_values('__time_range')
, but__time_range
is always giving me the literal time range selected, not a parsed[from, to]
couple of date objects. I get values such as:These variations are very difficult to deal with inside an SQL query.
I'd like to know if this is all I get or if there's an undocumented solution to my problem I don't know about. In its simplest from, I'd like to have filters available in the SQL as template params so that I can do things like:
Beta Was this translation helpful? Give feedback.
All reactions