Skip to content

Metric

A Metric represents a reusable aggregate calculation that can be referenced across charts.

Metrics centralize business logic for key measurements, ensuring consistency and making updates easier. They can be defined at the model level (model-scoped) or at the project level (global metrics).

Example

models:
  - name: orders
    sql: SELECT * FROM orders_table
    metrics:
      - name: total_revenue
        expression: "SUM(amount)"
        description: "Total revenue from all orders"
metrics:
  - name: revenue_per_user
    expression: "${ref(orders).total_revenue} / ${ref(users).total_users}"
    description: "Average revenue per user"

Attributes

Field Type Default Description
path string None A unique path to this object
name string None The unique name of the object across the entire project.
file_path string None The path to the file that contains the object definition.
expression string None SQL aggregate expression for the metric. For model-scoped metrics, use direct SQL aggregates (e.g., 'SUM(amount)', 'COUNT(DISTINCT id)'). For global metrics, can reference other metrics or fields using ${ref(model).field} or ${ref(metric_name)} syntax. Must be a valid aggregate function and cannot contain raw columns outside of aggregates.
description string None Human-readable description of what this metric represents.