User Guide Getting Started Help Center Documentation Community Training
New LookML
Old LookML
New LookML
Looker
  
English
Français
Deutsch
日本語
measure

Usage

view: view_name {
  measure: field_name {}
}

Hierarchy

measure

Accepts

A Looker identifier to name the measure

Definition

The measure parameter declares a new measure (aggregation) and specifies a name for that measure.

There are several criteria for a measure’s name:

There are many types of measures, as discussed further on this documentation page.

Examples

Create measures named product_count and total_value in a view named products:

view: products { measure: product_count { type: count } measure: total_value { sql: ${value} ;; type: sum } }

Things to Know

Measures in Joined Views

In order to have measures (aggregations) come through joins, you must define primary keys in all of the views involved in the join.

You can do this by adding the primary_key parameter to the primary key field definition in each view:

dimension: id { type: number primary_key: yes }

To correctly handle joined measures, Looker relies on you specifying a primary key where the values are completely unique, non-NULL values. If your data does not contain a primary key, consider whether the concatenation of several fields would result in a primary key of completely unique, non-NULL values. If your primary key is not unique or contains NULL values and your query includes data that reveal those issues, then Looker returns an error as described in this Community topic.

Measures Based on Other Measures

It is possible to define a measure that is based on another measure. The new measure must be of type: number to avoid nested-aggregation errors. See the documentation on type: number for measures for an example and explanation.

Top