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)
>   [![Chat with 
> Dosu](https://camo.githubusercontent.com/d9ffebb979729c9ef0fc4e3090dbae5b17cabbfec8afe378ada6b81913d6ad8a/68747470733a2f2f646f73752e6465762f646
 
f73752d636861742d62616467652e737667)](https://app.dosu.dev/a28d3c7e-a9d3-459e-9fb6-3a6f9ff4f357/ask?utm_source=github)
 [![Join 
Discord](https://camo.githubusercontent.com/d562c2df5e4567ea41d37f1d91a4da0839d8341037045b103b2da268998de17f/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6a6f696e2d3538363546323f6c6f676f3d646973636f7264266c6f676f436f6c6f723d7768697465266c6162656c3d)](https://go.dosu.dev/discord-bot)
 [![Share on 
X](https://camo.githubusercontent.com/4649f705e2396d6f328dbc8e800a0509c9c17b3b20253b36706c393df124b93d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f582d73686172652d626c61636b)](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

Reply via email to