home User Guide Getting Started Help Center Documentation Community Training Certification
menu
close
settings
Looker keyboard_arrow_down
language keyboard_arrow_down
English
Français
Deutsch
日本語
search
print
Looker documentation will be moving to cloud.google.com in mid-2022!
All the information you rely on will be migrated and all docs.looker.com URLs will be redirected to the appropriate page.
required_fields

Usage

view: view_name {
  measure: field_name {
    required_fields: [field_name, field_name, ]
  }
}
Hierarchy
required_fields
Possible Field Types
Dimension, Measure

Accepts
A square-bracketed list of dimensions and/or measures

Definition

The required_fields parameter lets you pull additional fields into a query when a user chooses a specific field. In this example, when the user chooses the Linked Name dimension, the url field is also pulled into the query:

dimension: linked_name { sql: ${name} ;; html: <a href="{{ row['websites.url'] }}" target="_new"></a> ;; required_fields: [url] }

Although the required fields are added to the query, they do not display to the user. If the required fields change the aggregation of the query, it can be confusing for the user.

For example, the LookML above will likely work, because there will likely be the same number of unique website names and website URLs. However, if the data listed several URLs for the same website name (such as naming both google.com and google.com/news as Google), then there could be multiple rows with the same name but different underlying URLs. Looker typically collapses identical names into one row, but it won’t do so in this case because it is acting as if the url field was also added.

Top