dosubot[bot] commented on issue #35884:
URL: https://github.com/apache/superset/issues/35884#issuecomment-3461379946

   <!-- Answer -->
   Here's a working example using adhoc_filters in the form_data parameter for 
filtering an embedded slice via the /explore/ URL in Superset 5.0.0:
   
   If you want to filter the column province_id to the value "11", your 
form_data should look like this (before URL encoding):
   
   ```json
   {
     "slice_id": 154,
     "adhoc_filters": [
       {
         "clause": "WHERE",
         "expressionType": "SIMPLE",
         "subject": "province_id",
         "operator": "IN",
         "comparator": ["11"]
       }
     ]
   }
   ```
   
   URL-encoded, this becomes:
   
   ```
   
form_data=%7B%22slice_id%22%3A154%2C%22adhoc_filters%22%3A%5B%7B%22clause%22%3A%22WHERE%22%2C%22expressionType%22%3A%22SIMPLE%22%2C%22subject%22%3A%22province_id%22%2C%22operator%22%3A%22IN%22%2C%22comparator%22%3A%5B%2211%22%5D%7D%5D%7D
   ```
   
   So your working URL should be:
   
   ```
   
https://my_superset.com/explore/?slice_id=154&standalone=1&form_data=%7B%22slice_id%22%3A154%2C%22adhoc_filters%22%3A%5B%7B%22clause%22%3A%22WHERE%22%2C%22expressionType%22%3A%22SIMPLE%22%2C%22subject%22%3A%22province_id%22%2C%22operator%22%3A%22IN%22%2C%22comparator%22%3A%5B%2211%22%5D%7D%5D%7D
   ```
   
   If you want to use a SQL expression instead, you can do:
   
   ```json
   {
     "slice_id": 154,
     "adhoc_filters": [
       {
         "clause": "WHERE",
         "expressionType": "SQL",
         "sqlExpression": "province_id = '11'"
       }
     ]
   }
   ```
   
   For multiple values, set comparator to an array, e.g., `"comparator": ["11", 
"12"]`.
   
   Make sure the column name matches exactly, and that your chart type supports 
filtering. If the filter still doesn't apply, check your Superset logs for 
errors and confirm the column is filterable in your dataset. This approach is 
the most reliable way to pass filters via URL in modern Superset versions 
([reference](https://github.com/apache/superset/discussions/31964), 
[reference](https://github.com/apache/superset/discussions/33574)).
   
   
   <!-- 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/6ff46db5-1dce-4f15-8107-f751133b0454?feedback_type=great_response)
 | 
[Irrelevant](https://app.dosu.dev/response-feedback/6ff46db5-1dce-4f15-8107-f751133b0454?feedback_type=irrelevant_answer)
 | 
[Incorrect](https://app.dosu.dev/response-feedback/6ff46db5-1dce-4f15-8107-f751133b0454?feedback_type=incorrect_sources)
 | 
[Verbose](https://app.dosu.dev/response-feedback/6ff46db5-1dce-4f15-8107-f751133b0454?feedback_type=too_verbose)
 | 
[Hallucination](https://app.dosu.dev/response-feedback/6ff46db5-1dce-4f15-8107-f751133b0454?feedback_type=hallucination)
 | [Report 
🐛](https://app.dosu.dev/response-feedback/6ff46db5-1dce-4f15-8107-f751133b0454?feedback_type=bug_report)
 | 
[Other](https://app.dosu.dev/response-feedback/6ff46db5-1dce-4f15-8107-f751133b0454?feedback_type=other)</sup>&nbsp;&nbsp;[![Chat
 with 
Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/a28d3c7e-a9d3-459e-9fb6-3a6f9ff4f357/ask?utm_source=githu
 b)&nbsp;[![Join 
Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share
 on 
X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/apache/superset/issues/35884)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to