AcceptsA LookML field name and the associated user attribute
Special RulesYou may apply multiple
access_filter lets you apply user-specific data restrictions. Unlike most LookML parameters, it needs to be used in conjunction with other settings in Looker in order to work properly. An
access_filter parameter is specific to a single Explore, so you need to make sure you apply an
access_filter parameter to each Explore that needs a restriction.
Please do not forget to add
access_filterto every Explore that needs it. If you forget to add
access_filterto an Explore that should have it, the data will not be restricted and users will be able to see all the data in that Explore.
The behavior of
access_filter would be similar to you sitting with a user and requiring them to apply one or more filters in the Explore UI before they run any query. For example, the user might only deal with a subset of your customers, so you would require that user to apply a customer name filter.
There are several steps you should take in order to implement an access filter:
- Decide what field or fields need to have a restriction. In the example above, your users might have a Customer Explore with a dimension called Name. The way that field would be referenced is
- Every user who will interact with the Explore in question needs a value for the access filter. In our example, every user will need the list of customer names they are allowed to see. You apply these values to each user or user group by utilizing Looker’s user attributes feature, which you can read about here. Let’s suppose we create an allowed_customers user attribute.
- Finally, connect the user attribute you created with the field that should use its value as a filter. In our example, we’ll want to connect the allowed_customers user attribute with the
customer.namefield, like this:
Limit users to seeing information about their sales region:
Limit users to seeing information about specific departments within their customers:
access_filter Requires Fully Scoped Field Names
If you write a field name without a view name, most parameters in Looker will assume a view name based on the place that the parameter is used. However,
access_filter does not work this way and requires you to write both the view name and field name.
For example, you might think this would work, and that
name would be interpreted as the customer name:
However, this is not the case, and you will receive an error. Instead you must write:
Even Admins Must Have Filter Values Set in the UI
Every user who accesses an Explore that uses
access_filter must have a value in the referenced user attribute. This even applies to those with the Admin role, despite the fact that they can see all data. Users who don’t have a user attribute value set will receive an error when trying to view the Explore.
To give an admin or another user access to all values of a string field, set the user attribute data type to String Filter (advanced), and use a value of
To give an admin or another user access to all values of a number field, set the user attribute data type to Number Filter (advanced), and use a value of
<0, >=0, NULL.