You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "richardfogaca (via GitHub)" <gi...@apache.org> on 2025/03/19 13:42:34 UTC

[D] Extra filters (to the chart as query params) [superset]

GitHub user richardfogaca created a discussion: Extra filters (to the chart as query params)

# Extra Filters

## What We Added

We added the ability to pass filters to Superset charts via URL parameters. This feature lets you:

1. Apply filters to charts without modifying the underlying configuration
2. Dynamically share filtered views of charts via URLs, extending beyond the static views available through permanent embed links
3. Integrate Superset with external applications that need to pass filter parameters

## How It Works

The extra filters feature works by:

1. Accepting filter definitions through a URL parameter called `extra_filters`
2. Applying these filters to individual charts or all charts in a dashboard
3. Preserving these filters when sharing chart links

This approach keeps the original chart configuration intact while allowing for dynamic filtering based on URL parameters.

## Working URL Example

This example shows how to filter a chart to show data for the UK (GBR), metric 1 greater than 3, and metric 2 greater than 0:

**Original chart URL (without filters):**

```
https://yourapplication.com/superset/explore/p/abcd1234/?form_data_key=form-data-key-123
```

**Simplified URL (decoded):**

```
https://yourapplication.com/superset/explore/p/abcd1234/?form_data_key=form-data-key-123&extra_filters={"upgrade_filters":[{"col":"country","op":"IN","val":"GBR"},{"col":"Metric 1","op":">","val":3},{"col":"Metric 2","op":">","val":0}]}
```

**Simplified URL (encoded):**

```
https://yourapplication.com/superset/explore/p/abcd1234/?form_data_key=form-data-key-123&extra_filters=%7B%22upgrade_filters%22%3A%5B%7B%22col%22%3A%22country%22%2C%22op%22%3A%22IN%22%2C%22val%22%3A%22GBR%22%7D%2C%7B%22col%22%3A%22Metric%201%22%2C%22op%22%3A%22%3E%22%2C%22val%22%3A3%7D%2C%7B%22col%22%3A%22Metric%202%22%2C%22op%22%3A%22%3E%22%2C%22val%22%3A0%7D%5D%7D
```

## Screenshot (chart with extra_filters)

<img width="941" alt="extra-filters-img" src="https://github.com/user-attachments/assets/84fbd582-9fbe-4ecb-9423-55daa35393d3" />


## Common Filter Operations

The extra filters feature supports all standard Superset filter operations:

- **Equality**: `==`, `!=`
- **Comparison**: `>`, `>=`, `<`, `<=`
- **Sets**: `IN`, `NOT IN`
- **Ranges**: `BETWEEN`
- **Text**: `LIKE`, `ILIKE`
- **Null checks**: `IS NULL`, `IS NOT NULL`

## Why This Matters

This feature solves several real-world problems:

1. **Dynamic Filtering**: Apply filters without modifying chart configurations
2. **Shareable Views**: Share specific filtered views of charts with colleagues
3. **External Integration**: Integrate Superset charts with other applications in your stack
4. **Parameterized Reporting**: Create links to pre-filtered chart views

The extra filters functionality makes Superset charts more flexible and easier to integrate with your existing systems and workflows.

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

----
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] Extra filters (to the chart as query params) [superset]

Posted by "jpdeloitte (via GitHub)" <gi...@apache.org>.
GitHub user jpdeloitte added a comment to the discussion: Extra filters (to the chart as query params)

Agree this will be highly valuable. The biggest value creator in my mind, which I think this solves for but Richard please confirm, is that this would enable a way to - in an embedded dashboard - retrieve a dashboard that is "pre-filtered" with a handful of selections. Equally valuable would be if this also opens up a method of retrieving (again in an embedded dashboard) what filters a user selected so that those can be saved to a database and later retrieved (essentially creating dynamic bookmarking functionality for embedded dashboards).

GitHub link: https://github.com/apache/superset/discussions/32754#discussioncomment-12994742

----
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] Extra filters (to the chart as query params) [superset]

Posted by "sfirke (via GitHub)" <gi...@apache.org>.
GitHub user sfirke added a comment to the discussion: Extra filters (to the chart as query params)

I would love to see this added to Superset. There are a lot of requests for this feature, for instance:

- In this one Dosubot gives an answer but I don't know if it's accurate: https://github.com/apache/superset/discussions/29910#discussioncomment-10293512
- https://github.com/apache/superset/discussions/30922
- https://github.com/apache/superset/discussions/33130
- https://github.com/apache/superset/discussions/31964

I don't know the current state of filtering with URL params. I think there's some functionality but it's not documented? Here's an open PR that would add filtering to dashboard reports via URL params: https://github.com/apache/superset/pull/32196

My use case is people who want to bookmark a filter for a dashboard in their browser so they don't have to always reset the filters to their desired combination.

GitHub link: https://github.com/apache/superset/discussions/32754#discussioncomment-13534555

----
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] Extra filters (to the chart as query params) [superset]

Posted by "mistercrunch (via GitHub)" <gi...@apache.org>.
GitHub user mistercrunch added a comment to the discussion: Extra filters (to the chart as query params)

It would be so great to have a simple, super intuitive URL "API" consistent on both explore and dashboard that's so simple you can just remember it without thinking, or document it in 5 lines of text.

like `?filter__{column_name}={value}` and for OR you'd just put it twice, like `?filter__country=Canada&filter__country=Peru`. Sure it can't do all the operators or the in-and-or-this-or-that-and-this. But just solving simple filters would be nice. 

`rison`, a standard to encode JSON-in-urls that we use internally in most places is super neat too and pretty intuitive if we wanted a slightly more complex/powerful implementation that supports JSON arrays or nested data structures (though we want to avoid the super complex stuff).

Early versions of Explore / Dashboard were stateful in the URL, but when charts got more complex, the amount of data started to exceed what a URL can support (I think it's 2k to 8k on most web servers, and having larger ones help people DDOS you...) so we moved away from that pattern.

I think there might still be undocumented url params. But it should probably be re-designed and re-implemented, in a consistent way across explore/dashboard.

GitHub link: https://github.com/apache/superset/discussions/32754#discussioncomment-13535018

----
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] Extra filters (to the chart as query params) [superset]

Posted by "mistercrunch (via GitHub)" <gi...@apache.org>.
GitHub user mistercrunch added a comment to the discussion: Extra filters (to the chart as query params)

Used to be a feature in early Superset - not sure if there's still a [documented/undocumented] way to do this. 

Note that we have support for Rison (url-friendly-encoded-json), and that it could be great to have simplified semantics for simple equalities. Currently you have to pass complex data structures where you specify operators (in, equals, different, greater, ...) but in many cases you just need `?filter=(country=Canada)` having shortcuts for simple equalities would be sweet, where you can easily compose a url without looking up the docs or url-encoding complex JSON

GitHub link: https://github.com/apache/superset/discussions/32754#discussioncomment-13008671

----
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] Extra filters (to the chart as query params) [superset]

Posted by "rusackas (via GitHub)" <gi...@apache.org>.
GitHub user rusackas added a comment to the discussion: Extra filters (to the chart as query params)

Seems highly valuable. Worth noting that @mistercrunch and @Vitor-Avila were also discussing similar filter URL schemas for dashboard context (embedded or otherwise), so these should probably be aligned in approach.

GitHub link: https://github.com/apache/superset/discussions/32754#discussioncomment-12916179

----
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] Extra filters (to the chart as query params) [superset]

Posted by "richardfogaca (via GitHub)" <gi...@apache.org>.
GitHub user richardfogaca edited a discussion: Extra filters (to the chart as query params)

# Extra Filters

## Contribution Summary

We added the ability to pass filters to Superset charts via URL parameters. This feature lets you:

1. Apply filters to charts without modifying the underlying configuration
2. Dynamically share filtered views of charts via URLs, extending beyond the static views available through permanent embed links
3. Integrate Superset with external applications that need to pass filter parameters

## How It Works

The extra filters feature works by:

1. Accepting filter definitions through a URL parameter called `extra_filters`
2. Applying these filters to individual charts or all charts in a dashboard
3. Preserving these filters when sharing chart links

This approach keeps the original chart configuration intact while allowing for dynamic filtering based on URL parameters.

## Working URL Example

This example shows how to filter a chart to show data for the UK (GBR), metric 1 greater than 3, and metric 2 greater than 0:

**Original chart URL (without filters):**

```
https://yourapplication.com/superset/explore/p/abcd1234/?form_data_key=form-data-key-123
```

**Simplified URL (decoded):**

```
https://yourapplication.com/superset/explore/p/abcd1234/?form_data_key=form-data-key-123&extra_filters={"upgrade_filters":[{"col":"country","op":"IN","val":"GBR"},{"col":"Metric 1","op":">","val":3},{"col":"Metric 2","op":">","val":0}]}
```

**Simplified URL (encoded):**

```
https://yourapplication.com/superset/explore/p/abcd1234/?form_data_key=form-data-key-123&extra_filters=%7B%22upgrade_filters%22%3A%5B%7B%22col%22%3A%22country%22%2C%22op%22%3A%22IN%22%2C%22val%22%3A%22GBR%22%7D%2C%7B%22col%22%3A%22Metric%201%22%2C%22op%22%3A%22%3E%22%2C%22val%22%3A3%7D%2C%7B%22col%22%3A%22Metric%202%22%2C%22op%22%3A%22%3E%22%2C%22val%22%3A0%7D%5D%7D
```

## Screenshot (chart with extra_filters)

<img width="941" alt="extra-filters-img" src="https://github.com/user-attachments/assets/84fbd582-9fbe-4ecb-9423-55daa35393d3" />


## Common Filter Operations

The extra filters feature supports all standard Superset filter operations:

- **Equality**: `==`, `!=`
- **Comparison**: `>`, `>=`, `<`, `<=`
- **Sets**: `IN`, `NOT IN`
- **Ranges**: `BETWEEN`
- **Text**: `LIKE`, `ILIKE`
- **Null checks**: `IS NULL`, `IS NOT NULL`

## Why This Matters

This feature solves several real-world problems:

1. **Dynamic Filtering**: Apply filters without modifying chart configurations
2. **Shareable Views**: Share specific filtered views of charts with colleagues
3. **External Integration**: Integrate Superset charts with other applications in your stack
4. **Parameterized Reporting**: Create links to pre-filtered chart views

The extra filters functionality makes Superset charts more flexible and easier to integrate with your existing systems and workflows.

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

----
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] Extra filters (to the chart as query params) [superset]

Posted by "richardfogaca (via GitHub)" <gi...@apache.org>.
GitHub user richardfogaca added a comment to the discussion: Extra filters (to the chart as query params)

Hi,

For those interested in testing the improvement, there's a branch where you can install and verify [here](https://github.com/richardfogaca/superset/tree/extra-filters-as-query-params)

Here's one example introducing the filter to the chart via URL:

`channel_name` in ["general", "beginners", "introductions", "apache-releases", "newsletter"]

decoded_url:

http://localhost:9000/explore/?form_data_key=K_A4DU7z8JQ&slice_id=103&extra_filters={"upgrade_filters":[{"col":"channel_name","op":"IN","val":["general","beginners","apache-releases","introductions","newsletter"]}]}

encoded url:

http://localhost:9000/explore/?form_data_key=K_A4DU7z8JQ&slice_id=103&extra_filters=%7B%22upgrade_filters%22%3A%5B%7B%22col%22%3A%22channel_name%22%2C%22op%22%3A%22IN%22%2C%22val%22%3A%5B%22general%22%2C%22beginners%22%2C%22apache-releases%22%2C%22introductions%22%2C%22newsletter%22%5D%7D%5D%7D

I'm also attaching a chart I created. Please let me know if you find this feature useful for superset :)

GitHub link: https://github.com/apache/superset/discussions/32754#discussioncomment-12703152

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