GitHub user dosubot[bot] added a comment to the discussion: Two Jinja date filters
<!-- Answer --> Superset currently does not support applying two independent date filters to different columns in a single query using Jinja—only one date filter (the dashboard's main time range) is exposed as `from_dttm`/`to_dttm`, and it applies to all temporal columns in your template. This is a known limitation and has been requested by others, but as of now, multiple distinct temporal filters for different columns are not natively supported ([source](https://github.com/apache/superset/issues/33725)). If you need to filter two columns by different date ranges, you would need to use custom filter controls and reference their values via the `filter_values` or `get_filters` Jinja functions, using the filter's name or column. For example, you can set up two native filters (one for each column), then in your SQL template, use something like: ```jinja {% set app_dates = filter_values('App_Status_date') %} {% set ref_dates = filter_values('Ref_Status_Date') %} {% if app_dates %} AND a1.statusdate BETWEEN DATE('{{ app_dates[0] }}') AND DATE('{{ app_dates[1] }}') {% endif %} {% if ref_dates %} OR r1.statusdate BETWEEN DATE('{{ ref_dates[0] }}') AND DATE('{{ ref_dates[1] }}') {% endif %} ``` This approach requires that your dashboard filters are set up as "field value" filters (not as the main time range filter), and that your SQL template references the correct filter names. It's not as seamless as the default time filter, but it allows you to work around the limitation ([source](https://github.com/apache/superset/blob/a1cbd2578e24ed6c72024e1d1cf195846ace05d7/superset/jinja_context.py)). Let me know if you need help with the exact Jinja or dashboard filter setup! <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/1ca17956-2094-4650-9896-543ee760d1c6?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/1ca17956-2094-4650-9896-543ee760d1c6?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/1ca17956-2094-4650-9896-543ee760d1c6?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/1ca17956-2094-4650-9896-543ee760d1c6?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/1ca17956-2094-4650-9896-543ee760d1c6?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/1ca17956-2094-4650-9896-543ee760d1c6?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/1ca17956-2094-4650-9896-543ee760d1c6?feedback_type=other)</sup> [](https://go.dosu.dev/discord-bot) [](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/apache/superset/discussions/33807) GitHub link: https://github.com/apache/superset/discussions/33807#discussioncomment-13500468 ---- This is an automatically sent email for [email protected]. To unsubscribe, please send an email to: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
