We often want to use a saved look as a sort of template and then dynamically override specific filter values, such as when we embed Looker into another application.
This article shows you how to do this.
Overriding Filters
The following example shows a Look where the default value for Orders Created At
is saved as on the day 2017-11-01
.
-
We see this URL (replacing
<instance_name.looker.com>
with the URL to your company's instance):
https://<instance_name.looker.com>/looks/:id:
In this case,toggle=fil
appears in the URL, because we have expanded the filters box to show the value. -
We can override the filter value by visiting a URL and changing it to this:
https://<instance_name.looker.com>/looks/:id?f[orders.created_date]=7+days
Looker automatically rewrites the URL into a unique query ID (
qid
) parameter representing this ad hoc query, just like on an Explore page. - This is the format of the query parameter:
f[view.field_name]=filter_expression&f[view.other_field]=filter_expression&etc
Read more about filter expressions on the Looker Filter Expressions documentation page.
Other Query Parameters
You can also override other query parameters besides the filter values, such as sort
or limit
, or even the visualization options. To see the full list of parameters:
- Create a query in the Explore page.
-
Using the gear menu in the top right corner, select Share.
- Copy the URL in the Expanded URL field and paste it into a text editor to see the entire URL with all parameters.
Embedding
This technique works with embedding, too:
- Add
/embed/
in front as usual, and it will work as above. - For SSO embed, make sure you add this to the
embed_path
component prior to signing the iframe URL.