Skip to content
Snippets Groups Projects
Unverified Commit a5fe34ef authored by Jeff Bruemmer's avatar Jeff Bruemmer Committed by GitHub
Browse files

docs - locked filter note (#46940)

parent eb43ebfb
No related branches found
No related tags found
No related merge requests found
......@@ -40,7 +40,7 @@ If you'd like to share your data with the good people of the internet, you can c
| -------------------------------------------------------------------------------------------------------- | ----------------------------------------- | ------------------------------- | ---------------------------------------------- |
| Display charts and dashboards | ✅ | ✅ | ✅ |
| Display interactive [filter widgets](https://www.metabase.com/glossary/filter_widget) | ✅ | ✅ | ✅ |
| Restrict data with [locked filters](./static-embedding-parameters.md#restricting-data-in-a-static-embed) | ❌ | ✅ | ❌ |
| Restrict data with [locked filters](./static-embedding-parameters.md#restricting-data-in-a-static-embed-with-locked-parameters) | ❌ | ✅ | ❌ |
| Restrict data with [sandboxes](../permissions/data-sandboxes.md) | ✅ | ❌ | ❌ |
| Use the [drill-through menu](https://www.metabase.com/learn/questions/drill-through) | ✅ | ❌ | ❌ |
| Self-serve via [query builder](https://www.metabase.com/glossary/query_builder) | ✅ | ❌ | ❌ |
......
......@@ -14,12 +14,16 @@ Parameters are pieces of information that are passed between Metabase and your w
Parameters can be signed or unsigned.
**Signed parameters**, such as filter names and values, must be added to your server code.
### Signed parameters
Signed parameters, such as filter names and values, must be added to your server code.
- [Editable parameters](#adding-a-filter-widget-to-a-static-embed)
- [Locked parameters](#restricting-data-in-a-static-embed)
- [Locked parameters](#restricting-data-in-a-static-embed-with-locked-parameters)
### Unsigned parameters
**Unsigned parameters**, such as appearance settings, should be added directly to your iframe's `src` attribute.
Unsigned parameters, such as appearance settings, should be added directly to your iframe's `src` attribute.
- [Default values for editable parameters](#populating-an-embedded-filter-widget-with-a-default-value)
- [Visibility settings for editable parameters](#hiding-filter-widgets-from-a-static-embed)
......@@ -102,7 +106,7 @@ Whenever you're adding a parameter to the embedding URL in your iframe's `src` a
- Parameter _values_ are case-sensitive (the values must match your data).
- Spaces should be replaced by underscores.
## Restricting data in a static embed
## Restricting data in a static embed with locked parameters
If you want to restrict the data that's displayed in an embedded dashboard or SQL question, you can set up a **locked parameter**. A locked parameter filters the data in a dashboard or SQL question _before_ the results are displayed to people in a static embed.
......@@ -128,6 +132,8 @@ Things to keep in mind if you need to make changes to your locked parameters.
Once you publish a chart or dashboard with a locked parameter, you _must_ include the name of the locked parameter in your server code. If you exclude the parameter name, the logs will gently remind you: `You must specify a value for :parameter in the JWT`.
### To turn off a locked parameter, pass an empty array as its value in the JWT
If you don't want the locked filter to apply, you can pass an empty array, `[]`, as the value for the parameter in the JWT.
### Make sure the filter name matches the locked parameter name
......@@ -138,12 +144,28 @@ If you change the name of a query builder filter that's used as a locked paramet
The values for the locked parameter in your server code should match your filter's values exactly. The best way to set multiple locked parameters, or pass multiple values to a locked parameter, is to pick a filter value under **Preview locked parameters** and [preview the server code generated by Metabase](./static-embedding.md#previewing-the-code-for-an-embed).
Using multiple locked parameters together will filter with `AND`, not `OR`. If you only want to apply a subset of the locked parameters, you must tell Metabase to [ignore the other locked parameters](#to-turn-off-a-locked-parameter-pass-an-empty-array-as-its-value-in-the-jwt).
## Locked parameters limit the values available to other editable parameters
Because locked parameters filter data _before_ the results are displayed in the embed, locked parameters limit the values available to other, editable filter widgets.
For example, say you're embedding a dashboard with two filters, State and City. If you lock the State parameter with the value "Vermont", Metabase will only display the City filter widget on the dashboard, and the dropdown menu for that City filter widget will be limited to cities in Vermont. While you don't explicitly link the two filters, the two filters behave implicitly like [linked filters](../dashboards/filters.md#linking-filters).
## Locked parameters on dashboards with SQL questions
If your [locked parameter](#restricting-data-in-a-static-embed) is linked to a dashboard filter that's in turn linked to a SQL question, you'll only be able to choose a _single_ value for your locked parameter.
If your [locked parameter](#restricting-data-in-a-static-embed-with-locked-parameters) is linked to a dashboard filter that's in turn linked to a SQL question, you'll only be able to choose a _single_ value for your locked parameter.
For example, let's say you have a dashboard filter called "Breakfast" with the values "Hash browns", "Muffin", and "Waffles". If the "Breakfast" filter is linked to _any_ SQL questions on the dashboard, you'll only be able to choose _one_ of the options for a locked parameter linked to the "Breakfast" filter.
## Using locked parameters to power custom widgets in your app
Because Metabase doesn't display locked parameters as filter widgets, you can use locked parameters to power custom filter widgets that you build in your app. You may want to build your own filter widget(s) to:
- Make the widgets more consistent with the look and feel of your application.
- Include custom logic. For example, to have a filter widget remember recent values.
- Reuse one dashboard in different ways in different parts of your app. For example, you may have a dashboard with multiple locked parameters, and use one parameter in one case, and another parameter in another case. Like a sales dashboard that in one part of your app is locked by "region", in another by "team".
## Customizing the appearance of a static embed
You can change the appearance of an embedded item by adding hash parameters to the end of the URL in your iframe's `src` attribute.
......
......@@ -12,7 +12,7 @@ In general, embedding works by displaying a Metabase URL inside an iframe in you
You can can't use static embeds with [data sandboxes](../permissions/data-sandboxes.md), [drill-through](https://www.metabase.com/learn/questions/drill-through), and user-specific data isn't captured in [usage analytics](../usage-and-performance-tools/usage-analytics.md) because signed JWTs don't create user sessions (server-side sessions). For those features, check out [interactive embedding](./interactive-embedding.md).
You can, however, restrict data in static embeds for specific people or groups by [locking parameters](./static-embedding-parameters.md#restricting-data-in-a-static-embed).
You can, however, restrict data in static embeds for specific people or groups by [locking parameters](./static-embedding-parameters.md#restricting-data-in-a-static-embed-with-locked-parameters).
## How static embedding works
......
......@@ -38,7 +38,7 @@ Caching takes less effort because it doesn't involve any changes to your schemas
## Embedded dashboard is slow compared to original dashboard
1. To speed up the embedded dashboard, set up a [locked parameter to pre-filter your data](../embedding/static-embedding-parameters.md#restricting-data-in-a-static-embed).
1. To speed up the embedded dashboard, set up a [locked parameter to pre-filter your data](../embedding/static-embedding-parameters.md#restricting-data-in-a-static-embed-with-locked-parameters).
**Explanation**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment