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