You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Can't Use Jinja Templating on Filtering Chart #34264
Jinja templating is no longer supported in chart filter values in recent Superset versions. This is an intentional change for security and maintainability—filter values in charts are now treated as plain SQL values and are not processed through the Jinja engine, so using template syntax like {% if ... %} in a filter will cause a SQL error instead of being evaluated as a template. In contrast, SQL Lab still processes the entire query as a Jinja template, which is why it works there.
If you need dynamic filtering with Jinja, you should include your template logic in the main SQL query or in virtual datasets, not in the filter value itself. For example, you can use Jinja in the SQL of a virtual dataset or in custom SQL expressions, and then use standard filter values in the chart controls. If you want to extend the Jinja context for supported places, you can use the ENABLE_TEMPLATE_PROCESSING feature flag and JINJA_CONTEXT_ADDONS in your superset_config.py, but this will not enable templating in chart filter values themselves. More details are in the docs.
If you need to implement conditional logic for filters, consider wrapping your logic in the main SQL using CASE WHEN or if/else blocks, as described in this issue. This approach ensures your queries remain compatible with the current Superset behavior.
Activity
dosubot commentedon Jul 22, 2025
Hi @mikysetiawan! I'm Dosu and I’m helping the superset team.
Jinja templating is no longer supported in chart filter values in recent Superset versions. This is an intentional change for security and maintainability—filter values in charts are now treated as plain SQL values and are not processed through the Jinja engine, so using template syntax like
{% if ... %}in a filter will cause a SQL error instead of being evaluated as a template. In contrast, SQL Lab still processes the entire query as a Jinja template, which is why it works there.If you need dynamic filtering with Jinja, you should include your template logic in the main SQL query or in virtual datasets, not in the filter value itself. For example, you can use Jinja in the SQL of a virtual dataset or in custom SQL expressions, and then use standard filter values in the chart controls. If you want to extend the Jinja context for supported places, you can use the
ENABLE_TEMPLATE_PROCESSINGfeature flag andJINJA_CONTEXT_ADDONSin yoursuperset_config.py, but this will not enable templating in chart filter values themselves. More details are in the docs.If you need to implement conditional logic for filters, consider wrapping your logic in the main SQL using
CASE WHENorif/elseblocks, as described in this issue. This approach ensures your queries remain compatible with the current Superset behavior.To reply, just mention @dosu.
Docs are dead. Just use Dosu.
mikysetiawan commentedon Jul 22, 2025
thanks!