GitHub user stgztsw added a comment to the discussion: The SQL can be executed correctly, but fails to be saved as a dataset.
> You can use Jinja's `filter_values` in any part of your virtual dataset > SQL—including subqueries—even if the filtered column isn't in the final > output. Superset injects dashboard or chart filter values into your SQL at > runtime, as long as the filter is mapped to the correct column in the > dataset. You don't need to expose the filtered column in the SELECT clause; > referencing it in the subquery is enough. Just use defensive Jinja like: > > ```sql > {% set is_apply_values = filter_values('is_apply') %} > {% if is_apply_values %} > and is_apply in {{ is_apply_values | where_in }} > {% endif %} > ``` > > This pattern works in subqueries, joins, or any nested SQL. If no filter is > selected, the clause is omitted, so you avoid SQL errors. The > `${rt.name:mechine_version}` and `${rb.product_id:product_id}` syntax is not > standard Superset or Jinja—replace these with Jinja templating if you want > dynamic filter binding. > > If you want a filter to only apply inside a subquery and not affect the outer > query, you can use `filter_values('col', remove_filter=True)`. > > No extra configuration is needed beyond mapping the dashboard filter to the > dataset column and enabling `ENABLE_TEMPLATE_PROCESSING`. This approach is > fully supported in Superset 6.x for complex/nested queries—see [this > reference](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset/jinja_context.py) > for backend details. > > Let me know if you want a concrete example for your specific columns or more > help with the Jinja syntax! > > _To reply, just mention [@dosu](https://go.dosu.dev/dosubot)._ > > How did I do? > [Good](https://app.dosu.dev/response-feedback/54f66894-8707-459d-aafe-8db146e8a92c?feedback_type=great_response) > | > [Irrelevant](https://app.dosu.dev/response-feedback/54f66894-8707-459d-aafe-8db146e8a92c?feedback_type=irrelevant_answer) > | > [Incorrect](https://app.dosu.dev/response-feedback/54f66894-8707-459d-aafe-8db146e8a92c?feedback_type=incorrect_sources) > | > [Verbose](https://app.dosu.dev/response-feedback/54f66894-8707-459d-aafe-8db146e8a92c?feedback_type=too_verbose) > | > [Hallucination](https://app.dosu.dev/response-feedback/54f66894-8707-459d-aafe-8db146e8a92c?feedback_type=hallucination) > | [Report > 🐛](https://app.dosu.dev/response-feedback/54f66894-8707-459d-aafe-8db146e8a92c?feedback_type=bug_report) > | > [Other](https://app.dosu.dev/response-feedback/54f66894-8707-459d-aafe-8db146e8a92c?feedback_type=other) > [](https://app.dosu.dev/a28d3c7e-a9d3-459e-9fb6-3a6f9ff4f357/ask?utm_source=github) [](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/35171) Hi @dosu How can i mapper the filter to column. In dataset editor, filter can only be selected as the dataset output column <img width="1352" height="1198" alt="image" src="https://github.com/user-attachments/assets/278b6fe4-e39b-4fb4-aaa0-a3a26b35ba75" /> So, how can I mapper the filter to parameter which is not dataset output column. GitHub link: https://github.com/apache/superset/discussions/35171#discussioncomment-14439101 ---- This is an automatically sent email for notifications@superset.apache.org. To unsubscribe, please send an email to: notifications-unsubscr...@superset.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: notifications-unsubscr...@superset.apache.org For additional commands, e-mail: notifications-h...@superset.apache.org