Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add instructions on regex based dashboard filters #387

Merged
merged 1 commit into from
Oct 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions docs/app/visualization/Dashboards.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,38 @@ template
a. [From Preset website](https://preset.io/blog/intro-jinja-templating-apache-superset/)
b. [From Apache Superset website](https://superset.apache.org/docs/configuration/sql-templating/)


### Having More Control Of Dashboard Filters with Jinja Templates: Regex or Other Variations
Filters at the dashboard level by default require a dataset and a column to be associated with them.
To apply the filters, you either need to manually select the individual filters or click
`Select All`. With Jinja templating, you can have more flexibility in your filters such as the use
of regex. Follow these steps to have Jinja templated regex filters or other variations

1. Enter the `Edit chart` of the chart you wish to add the filter for
2. In the `Filters` section, add the following

```sql
REGEXP_CONTAINS(
my_column_to_filter,
ARRAY_TO_STRING({{ filter_values('column_that_has_regex') }}, '|')
)
```

You do not need to have an if else expression in the Jinja template here.

3. Save the chart
4. At the dashboard level, click `+ ADD/EDIT FILTERS`
5. Add a new filter on some dataset that contains the column 'column_that_has_regex'. Make sure the
column name and dataset name do not exist in your dashboard to prevent your charts from inheriting
it and doing a hard filter.
6. This can contain pre-defined regex expressions or you can pre-filter the column in the
`Pre-filter available values` in the **Filter Configuration** section to remove all values in case
this is a dummy dataset and you mostly just want the users to type in the regex manually.
7. Save the filters.
8. You are now ready to have regex based filters in your dashboard!



## Editing dashboards

To edit a dashboard:
Expand Down