Usage
dimension: field_name {
primary_key: yes
}
}
Hierarchyprimary_key |
Possible Field TypesDimensionAcceptsA Boolean (yes or no) |
Definition
The primary_key
parameter specifies that a dimension is the primary key for its view. The default value is false
. For example:
The primary_key
parameter:
- Helps Looker to avoid unnecessary
GROUP BY
clauses - Is necessary to make the
foreign_key
parameter work properly - Is required for the proper functioning of symmetric aggregates. When you join views with measures (aggregates), a
primary_key
must be defined on each side of the join to properly calculate the aggregations.
If you have a primary key that is comprised of multiple columns, you can create a dimension that concatenates those columns, then declare that as your primary key. For example:
A dimension_group
cannot be used as a primary key if it specifies more than one timeframe
.