always_filter

LookML
Version

On this Page
Docs Menu

Go to Explore Parameter List

Usage

      always_filter is a child of
explore
explore: view_name
...
always_filter:
1st
Tab
2nd
Tab
field_name: 'default value'
the name of an existing field,
followed by a colon,
followed by a looker filter expression

Definition

always_filter enables you to require users to include a certain set of filters that you define. You also define a default value for the filters. Though users may change your default value for their query, they cannot remove the filter entirely.

The field_name can be the name of a dimension or measure. If you need to reference a dimension or measure that is part of a joined view, instead of the explore, use view_name.field_name. For example:

- explore: order always_filter: id: '123' customer.id: '789' joins: - join: customer sql_on: ${order.customer_id} = ${customer.id}

Here the id filter refers to the id field from order. The customer.id filter refers to the id field from customer. This example also demonstrates that multiple filters are allowed.

The default values that you specify accept these types of expressions.

Examples

Force the user to use an Order ID filter (with a default value of “123” that they can change):

- explore: order always_filter: id: '123'

Force the user to use an Order ID filter (with a default value of “123” or “234” that they can change):

- explore: order always_filter: id: '123, 234'

Force the user to use an Order ID filter (default value of “123”), an Order City filter (default value of “Chicago”), and a Customer Age filter (default value of “18”):

- explore: order always_filter: id: '123' city: 'Chicago' customer.age: '18' joins: - join: customer sql_on: ${order.customer_id} = ${customer.id}

Common Challenges

A User Cannot Remove A Filter Specified By always_filter

The Explore UI does not allow a user to remove a filter that has been added by always_filter. If you do have a desire to pre-load filters with an explore, in such a way that users can completely remove them, consider saving a query with the suggested filters, and having users start with that saved query.

The always_filter Overrides a Default_Value Filter Setting

If an explore specifies a value for this field in an always_filter parameter, then that setting overrides the default_value setting for the field.

Things to Know

If You Want Filters That A User Cannot Change Consider sql_always_where

If you want an explore to have filters that are the same for everyone, and cannot be changed in any way, you can use sql_always_where.

If You Want User-Specific Filters That Can’t Be Changed Consider access_filter_fields

If you want an explore to have filters that are specific to each user, and cannot be changed in any way, you can use access_filter_fields.

Still have questions?
Go to Discourse - or - Email Support
Top