GitHub user dosubot[bot] added a comment to the discussion: How to Apply 
Dynamic Default Filter Values in Superset Dashboards

<!-- Answer -->
Superset does not natively support dynamic default filter values that update 
based on dataset values or SQL results—default filter values are static and 
stored in dashboard metadata, and the UI applies whatever is present there 
[source](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset/views/utils.py#L299-L385).

To achieve dynamic defaults, you have a few practical options:

- **Automate metadata updates:** Run an external job or script that queries 
your dataset for the desired default (like the latest date or top category), 
then updates the dashboard's `default_filters` or `native_filter_configuration` 
in the metadata via the Superset API or direct DB update. The dashboard will 
use these values on load 
[source](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset/daos/dashboard.py#L179-L392).

- **Inject filter state via URL or API:** You can preselect filter values by 
passing them in the dashboard URL (rison-encoded), posting filter state to the 
API and using the returned key in the URL, or posting the full dashboard state 
and using a permalink key 
[source](https://github.com/apache/superset/issues/35884). This requires 
external logic to determine the correct value.

- **Custom extension/plugin:** Superset recently added MCP (Model Context 
Protocol) abstractions, which could be used to register custom logic for things 
like dynamic filter defaults, but this would require custom development and is 
not a built-in feature [source](https://github.com/apache/superset/pull/36151).

The most maintainable approach is to automate updating dashboard metadata with 
fresh defaults based on your data. The UI and rendering logic will always use 
whatever defaults are present in the metadata, so this method works reliably.

Let me know if you want a sample workflow or code snippet for automating 
metadata updates!


<!-- 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/7bbfb213-c325-4d3a-b729-51d009717bc7?feedback_type=great_response)
 | 
[Irrelevant](https://app.dosu.dev/response-feedback/7bbfb213-c325-4d3a-b729-51d009717bc7?feedback_type=irrelevant_answer)
 | 
[Incorrect](https://app.dosu.dev/response-feedback/7bbfb213-c325-4d3a-b729-51d009717bc7?feedback_type=incorrect_sources)
 | 
[Verbose](https://app.dosu.dev/response-feedback/7bbfb213-c325-4d3a-b729-51d009717bc7?feedback_type=too_verbose)
 | 
[Hallucination](https://app.dosu.dev/response-feedback/7bbfb213-c325-4d3a-b729-51d009717bc7?feedback_type=hallucination)
 | [Report 
šŸ›](https://app.dosu.dev/response-feedback/7bbfb213-c325-4d3a-b729-51d009717bc7?feedback_type=bug_report)
 | 
[Other](https://app.dosu.dev/response-feedback/7bbfb213-c325-4d3a-b729-51d009717bc7?feedback_type=other)</sup>

[![Chat with 
Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/a28d3c7e-a9d3-459e-9fb6-3a6f9ff4f357/ask?utm_source=github)&nbsp;[![Open
 in 
Cursor](https://dosu.dev/dosu-in-cursor.svg)](https://cursor.com/link/prompt?text=Superset%20does%20not%20natively%20support%20dynamic%20default%20filter%20values%20that%20update%20based%20on%20dataset%20values%20or%20SQL%20results%E2%80%94default%20filter%20values%20are%20static%20and%20stored%20in%20dashboard%20metadata%2C%20and%20the%20UI%20applies%20whatever%20is%20present%20there%20%5Bsource%5D%28https%3A//github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset/views/utils.py%23L299-L385%29.%0A%0ATo%20achieve%20dynamic%20defaults%2C%20you%20have%20a%20few%20practical%20options%3A%0A%0A-%20%2A%2AAutomate%20metadata%20updates%3A%2A%2A%20Run%20an%20external%20job%20or%20script%20that%20queries%20your%20dataset%20for%20the%20desired%20default%20%28like%20the%20latest%20date%20or%20top%20category%29%2C%20t
 
hen%20updates%20the%20dashboard%27s%20%60default_filters%60%20or%20%60native_filter_configuration%60%20in%20the%20metadata%20via%20the%20Superset%20API%20or%20direct%20DB%20update.%20The%20dashboard%20will%20use%20these%20values%20on%20load%20%5Bsource%5D%28https%3A//github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset/daos/dashboard.py%23L179-L392%29.%0A%0A-%20%2A%2AInject%20filter%20state%20via%20URL%20or%20API%3A%2A%2A%20You%20can%20preselect%20filter%20values%20by%20passing%20them%20in%20the%20dashboard%20URL%20%28rison-encoded%29%2C%20posting%20filter%20state%20to%20the%20API%20and%20using%20the%20returned%20key%20in%20the%20URL%2C%20or%20posting%20the%20full%20dashboard%20state%20and%20using%20a%20permalink%20key%20%5Bsource%5D%28https%3A//github.com/apache/superset/issues/35884%29.%20This%20requires%20external%20logic%20to%20determine%20the%20correct%20value.%0A%0A-%20%2A%2ACustom%20extension/plugin%3A%2A%2A%20Superset%20recently%20added%20MCP%20%
 
28Model%20Context%20Protocol%29%20abstractions%2C%20which%20could%20be%20used%20to%20register%20custom%20logic%20for%20things%20like%20dynamic%20filter%20defaults%2C%20but%20this%20would%20require%20custom%20development%20and%20is%20not%20a%20built-in%20feature%20%5Bsource%5D%28https%3A//github.com/apache/superset/pull/36151%29.%0A%0AThe%20most%20maintainable%20approach%20is%20to%20automate%20updating%20dashboard%20metadata%20with%20fresh%20defaults%20based%20on%20your%20data.%20The%20UI%20and%20rendering%20logic%20will%20always%20use%20whatever%20defaults%20are%20present%20in%20the%20metadata%2C%20so%20this%20method%20works%20reliably.%0A%0ALet%20me%20know%20if%20you%20want%20a%20sample%20workflow%20or%20code%20snippet%20for%20automating%20metadata%20updates%21)&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/inte
 
nt/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/apache/superset/discussions/36438)

GitHub link: 
https://github.com/apache/superset/discussions/36438#discussioncomment-15169124

----
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]

Reply via email to