You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "Vinayselukar21 (via GitHub)" <gi...@apache.org> on 2025/12/05 07:12:33 UTC

[D] How to Apply Dynamic Default Filter Values in Superset Dashboards [superset]

GitHub user Vinayselukar21 created a discussion: How to Apply Dynamic Default Filter Values in Superset Dashboards

### Query: How to Apply Dynamic Default Filter Values in Superset Dashboards

Hi everyone,

We are trying to implement dynamic default filter values on dashboards in Apache Superset and wanted some clarity on whether this is achievable natively or through an extension/workaround.

### What we are trying to achieve

We want the default filter selection to be automatically set based on values present in the dataset, instead of manually defining default values in the filter configuration.

### Example Use Case

- For a time filter: auto-select the latest available date in the dataset.

- For category filters: pre-select a value based on dataset logic (e.g., highest revenue region, currently active status, user-specific values).
 
- Default filter should update dynamically as new data is ingested.

### Current Challenge

Superset allows manually configured default filter values, but these values are static.
We are looking for a way where the default selected value should change dynamically depending on the most recent or calculated result from the underlying table.

### Questions

1. Is there a built-in way in Superset to set filters dynamically based on data/SQL result?
 
2. If not natively supported, is there any recommended workaround such as:

      -  Custom Dashboard Plugin?      
      -  Using chart pre-query to push value into filter? 

### Goal

Create dashboards where users always see the most relevant view without having to manually pick filter values every time — particularly when data updates frequently.

Any guidance, examples, or references would be greatly appreciated.
Thanks in advance!
<img width="881" height="821" alt="image" src="https://github.com/user-attachments/assets/e192c97d-b3c1-42b5-ba61-0e4adb9fd93f" />

<img width="1892" height="917" alt="Screenshot 2025-12-05 122512" src="https://github.com/user-attachments/assets/d8a4eeeb-0022-4778-bafb-731938da98e8" />


GitHub link: https://github.com/apache/superset/discussions/36438

----
This is an automatically sent email for notifications@superset.apache.org.
To unsubscribe, please send an email to: notifications-unsubscribe@superset.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [D] How to Apply Dynamic Default Filter Values in Superset Dashboards [superset]

Posted by "dosubot[bot] (via GitHub)" <gi...@apache.org>.
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 notifications@superset.apache.org.
To unsubscribe, please send an email to: notifications-unsubscribe@superset.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [D] How to Apply Dynamic Default Filter Values in Superset Dashboards [superset]

Posted by "dosubot[bot] (via GitHub)" <gi...@apache.org>.
GitHub user dosubot[bot] edited a comment on 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?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=reply-with-mention&utm_term=apache%2Fsuperset).*

---

Docs are dead. Just use [Dosu](https://dosu.dev?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=static-docs-tagline&utm_term=apache%2Fsuperset).

[![Leave Feedback](https://img.shields.io/badge/Leave%20Feedback-555555?style=flat)](https://app.dosu.dev/response-feedback?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=static-docs-feedback&utm_term=apache%2Fsuperset&message_id=7bbfb213-c325-4d3a-b729-51d009717bc7) [![Ask Dosu about superset](https://img.shields.io/badge/Ask%20Dosu%20about%20superset-2f7b3f?style=flat&logo=data%3Aimage%2Fsvg%2Bxml%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2IC02LjU3OTE5IDQ3LjgwMTMgLTYuNTc5MTlWNy42MTUzMlpNNDIuNTgwNSA3LjYxNTMySDQ3LjgwMTNWLTYuNTc5MTlINDIuNTgwNVY3LjYxNTMyWk00MC43MDQgNy42MTUzMkg0Mi41ODA1Vi02LjU3OTE5SDQwLjcwNFY3LjYxNTMyWiIgZmlsbD0iYmxhY2siIG1hc2s9InVybCgjZG9zdS1kLWN1dG91dCkiLz48cGF0aCBkPSJNNjguOTIxNSAzNi4wMTM1QzY4LjkyMTUgMzYuMDEzNSA2NS43MzY5IDQ5LjQ3MzggNTEuNDIzMSA0OS40NzM4QzM3LjEwOTMgNDkuNDczOCAzMi41Nzg3IDM3LjM1OTYgMzIuNTc4NyAzNi4wMTM1IiBzdHJva2U9ImJsYWNrIiBzdHJva2Utd2lkdGg9IjcuNjkxNjEi
 IHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIvPjxwYXRoIGQ9Ik0wLjM0ODYzMyA4NS40OTQ2QzAuMzQ4NjMzIDg1LjQ5NDYgMjkuNDg1NiA4NS44MzA5IDM0LjgwOSA4NS42OThDNDQuODMzNyA4NS40NDc3IDUxLjI4NzIgODQuNDAyIDU3LjUyNjkgNzguOTcyNEM2Mi44MTI5IDc0LjM3MjcgNzUuMTM0MiA1OS42ODM2IDc1LjEzNDIgNTkuNjgzNiIgc3Ryb2tlPSJibGFjayIgc3Ryb2tlLXdpZHRoPSI2LjE2NDgyIi8%2BPC9zdmc%2B)](https://github.dosu.com/apache/superset?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=static-docs-ask-repo&utm_term=apache%2Fsuperset) [![Share Dosu with your team](https://img.shields.io/badge/Share%20Dosu%20with%20your%20team-1f6feb?style=flat)](https://app.dosu.dev/signup?referrer=openSource&source=github-footer&utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=static-docs-share-team&utm_term=apache%2Fsuperset)

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

----
This is an automatically sent email for notifications@superset.apache.org.
To unsubscribe, please send an email to: notifications-unsubscribe@superset.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org