Including User type in a filter

I need to take a user role (i.e., Viewer versus User) into consideration when making queries. How can I check the role in a filter? I’m looking for something simple if possible, i.e. via a sql_on statement, unless templates are the only way to do it.

For example, suppose I have a column called “Clearance” in the database. I want Users to be able to see all rows in the database, but Viewers should only see those rows with a clearance value of “5” or less. 

Is this doable?

Thanks.

0 1 192
1 REPLY 1

This use case seems well-suited for user attributes and access filters, which provide row-level security by inserting conditions in the SQL WHERE clause.

Using the example given, we can use these steps:

  1. Create a user attribute called “clearance_access” with Data Type set to “Number Filter (advanced)”
  2. Set values at the individual user and/or group level (note that we can’t set values at the role level). Users in one group may be able to see all rows (we can use a wildcard character as the value: <0, >=0, NULL) whereas users in another group may only see values at or under 5 (we can use <=5).
  3. In the LookML model file, apply an access filter:
      access_filter: {

        field: view_name.clearance_column

        user_attribute: clearance_access

      }
Top Labels in this Space
Top Solution Authors