Looker 3.20 introduces new ways to label fields.
Until now, you’re probably familiar with fields appearing like User Age. You’ll now have much greater freedom about how you want fields to appear to users in the field picker.
Field labels now consist of two parts:
- The
view_label
begins the name of the field, and is the view name by default (“User” in the example above) - The
label
ends the name of the field, and is the dimension or measure name by default (“Age” in the example above)
If you’ve enabled the new field picker that was introduced in 3.18 (by going to the Labs section of Looker’s admin settings), fields are grouped by their view.
In 3.20, views can now be re-labeled so that they are logically grouped together in for end users in the field picker. You’ll still reference the fields in the way you’re used to when writing LookML.
Default Behavior
Suppose you had the following model:
- explore: order
joins:
- join: user
foreign_key: user_id
- join: user_order_facts
foreign_key: user_id
- view: user
fields:
- dimension: age
- view: user_order_facts
fields:
- dimension: lifetime_orders
The resulting explore would have three separate views named:
- Order
- User
- User Order Facts
The two dimensions would be displayed as:
User Age
User Order Facts Lifetime Orders
Both of these fields are really attributes of User. The fact that “Lifetime Orders” exists in a separate view isn’t all that interesting to the person exploring the data. It would be really nice if “User Order Facts Lifetime Orders” displayed as “User Lifetime Orders” instead.
In 3.20 there are a couple of mechanisms to do this:
Change the view_label
for All Fields in a View
In the following example, all the fields in the User Order Facts view would appear as User instead:
- explore: order
joins:
- join: user
foreign_key: user_id
- join: user_order_facts
view_label: User # Change the view_label
foreign_key: user_id
Change the view_label
for Individual Fields
There are times (e.g. in a wide events table) that you might want to label attributes. In these cases you might want to declare the view_label
and label
for individual fields:
- view: event
fields:
- dimension: user_name
view_label: User
label: Name
sql: ${TABLE}.user_name
- dimension: user_id
view_label: User
label: ID
sql: ${TABLE}.user_id
- measure: user_count
view_label: User
label: Count
type: count_distinct
sql: ${user_id}
In LookML these fields are called:
- event.user_name
- event.user_id
- event.user_count
However, they would appear in the field picker as:
User Name
User ID
User Count