sets

LookML
Version

On this Page
Docs Menu

Go to View Parameter List

Usage

sets is a child of
view
view: view_name
...
sets: desired name of set
se t_name:
1st
Tab
2nd
Tab
3rd
Tab
- field_name
name of one or more existing
dimensions or measures

Definition

sets begins a section of LookML where you can create sets of fields. Sets can be useful when referenced in other parameters, like fields and drill_fields, that need lists of fields.

You define each set within the sets parameter. An individual set can contain any number of dimensions, measures, or filter fields from the current view, including the individual dimensions generated by a dimension group. It can also contain fields from other views using the view_name.field_name syntax.

For example:

sets: my_first_set: - dimension_one - another_view.dimension_two - measure_one

The sets parameter can contain any number of sets. For example:

sets: my_first_set: - dimension_one - another_view.dimension_two - measure_one my_second_set: - dimension_three - measure_two

Sets can also contain other sets. To differentiate a set name from the name of a dimension or measure, add a * character. For example:

sets: my_first_set: - dimension_one - another_view.dimension_two - measure_one my_second_set: - dimension_three - measure_two my_third_set: - my_first_set* - my_second_set*

The set named my_third_set will contain these fields:

  • dimension_one
  • another_view.dimension_two
  • measure_one
  • dimension_three
  • measure_two

Finally, fields can be excluded using the - character. For example:

sets: my_first_set: - dimension_one - another_view.dimension_two - measure_one my_second_set: - dimension_three - measure_two my_third_set: - my_first_set* - my_second_set* my_fourth_set: - my_first_set* - -measure_one

The set named my_fourth_set will contain these fields:

  • dimension_one
  • another_view.dimension_two

Examples

Make a set called financial_data

sets: financial_data: - subtotal - shipping - tax - total - cost - profit

Make a set called basic_customer_data in the customer view that also references the customer_order_facts view

sets: basic_customer_data: - name - address - status - customer_order_facts.lifetime_orders - customer_order_facts.lifetime_revenue

Common Challenges

Fields From Another View Must Be Joined To The explore Where sets Is Being Used

If you want to reference a field in sets that is from another view, you need to make sure that view is joined to the explore where sets is being used. For example, this will not work:

Model File

- explore: order

View File

- view: order sets: customer_info: - customer.name

Here customer hasn’t been joined to order, so a field from customer can’t be referenced in the customer_info set.

Adding Fields From A dimension_group To A Set

When you want to add fields from a dimension_group to a set, you’ll need to add each time frame dimension individually. For example, consider this dimension_group:

- dimension_group: created type: time timeframes: [date, week, month] sql: ${TABLE}.created_at

You cannot add the day, week, and month dimension to a set like this:

sets: created_timeframes: - created

Instead, you’ll need to add the timeframes individually, like this:

sets: created_timeframes: - created_date - created_week - created_month

Still have questions?
Go to Discourse - or - Email Support
Top