Anfra docs
Concepts

Dimensions

Non-aggregated fields for grouping and filtering metrics

A dimension is a raw, non-aggregated field — a category, date, or other attribute — used to group and filter metrics. Where a metric answers "how much?", a dimension answers "broken down by what?".

Defining a dimension

Dimensions are usually defined on a data model, close to the column they come from:

Model orders {
  dimension order_date {
    definition: @sql {{ #SOURCE.created_at }};;
    type: 'date'
  }

  dimension status {
    definition: @sql {{ #SOURCE.status }};;
    type: 'text'
  }
}

A dataset can also expose dimensions that combine fields across its included models:

Dataset sales {
  dimension customer_country {
    model: customers
    definition: @sql {{ customers.country }};;
  }
}

Common types

  • Date/time — supports querying at different grains (day, week, month, …) without redefining the dimension.
  • Categorical — a discrete attribute like status or plan, used for filtering and grouping.

Putting it together

Once a dataset has metrics and dimensions defined, anyone can query revenue grouped by order_date at a month grain, filtered to a specific customer_country — without writing SQL or repeating the underlying joins.

On this page