fields

LookML
Version

On this Page
Docs Menu

Go to Join Parameter List

This page refers to the fields parameter that is part of an join

fields can also be used as part of an explore, described here

fields can also be used as part of a view, described here

Usage

fields is a child of
join is a child of
joins is a child of
explore
explore: view_name_1
joins:
join: view_name_2
...
1st
Tab
2nd
Tab
3rd
Tab
fields: [field_name]
one or more field or set names

Definition

fields at the join level enables you to specify which fields from a joined view are brought into an explore. If you do not use fields Looker defaults to adding all fields from the view.

A list of fields may be used, like [field_a, field_b].

You can also reference a set of fields (which are created by the sets parameter), like [set_a*]. The asterisk tells Looker that you are referencing a set name instead of a field name.

Examples

Only add the field called name from the customer view to the order explore:

- explore: order joins: - join: customer sql_on: ${order.customer_id} = ${customer.id} fields: [name]

Add the fields called name, address, and age from the customer view to the order explore:

- explore: order joins: - join: customer sql_on: ${order.customer_id} = ${customer.id} fields: [name, address, age]

Add the set of fields called order_fields from the customer view to the order explore:

- explore: order joins: - join: customer sql_on: ${order.customer_id} = ${customer.id} fields: [order_fields* ]

Common Challenges

fields Can Only Reference Fields From Its Own join

fields will be a child of a join, which references a view. Any dimensions or measures that are referenced in fields must be a part of that view. For example, suppose we have:

- explore: order joins: - join: customer sql_on: ${order.customer_id} = ${customer.id} fields: [name]

In order to work properly, a dimension or measure called name must exist in the customer view.

Things to Know

fields Can Only Include Items When Used With join, But Can Also Exclude Items When Used With explore

When fields is nested under a join parameter, you can only include fields. For example, if you had 100 fields, and you only wanted to exclude one of them, you would need to list out all 99 fields that you did want.

However, there is a better method. If you nest fields under explore instead, you can take advantage of the ALL_FIELDS set and then exclude fields. For example:

- explore: order fields: [ ALL_FIELDS*, -customer.unwanted_field_a, -customer.unwanted_field_b ] joins: - join: customer sql_on: ${order.customer_id} = ${customer.id}

Notice how we were able to reference fields from the joined view customer in the explore level’s fields parameter by using the syntax view_name.field_name.

Different Types Of fields Parameters Are Applied At Different Times

This page describes fields when it is nested under a join parameter. There is also a similar fields parameter that is nested under explore. When both are used at the same time, you need to understand the order in which they are applied so that you can create the desired behavior.

First, all of the fields parameters under join are applied. This creates the set of fields that the explore can choose from. Consider this example:

- explore: orders joins: - join: users fields: [name] sql_on: ${orders.user_id} = ${users.id}

In this case the fields that will be available are everything from orders, and name from users. This is the group of fields what would be in the ALL_FIELDS* set (described above).

Now, if we add a fields parameter under explore, we’re adding a restriction on top of that set. Suppose we did this:

- explore: orders fields: [orders.price, users.address] joins: - join: users fields: [name] sql_on: ${orders.user_id} = ${users.id}

In this case:

  • price from orders will show up as expected, because it is in the ALL_FIELDS* set we created
  • address from users won’t show up, because it wasn’t included when users was joined in (only name was)
  • name from users won’t show up either, because we didn’t add it to the explore in the row fields: [orders.price, users.address]
Still have questions?
Go to Discourse - or - Email Support
Top