Skip to main content

Metric properties

Metrics define measurable quantities that you can query through the Semantic Layer. You define them in different places, depending on your dbt version:

  • In a model using the latest YAML spec. Top-level metrics: list on a model that has semantic modeling enabled, alongside semantic_model: and columns:. Available in the dbt platform Latest release track and the dbt Fusion engine.
  • In the standalone legacy YAML spec. Refer to Creating metrics for more information.
Availability

The latest YAML spec is supported in the following environments:

  • dbt platform (Latest release track)
  • dbt Fusion engine
  • dbt Core v1.12

For more information, refer to Migrate to the latest YAML spec.

(Applies to dbt v1.12 and later)

Latest spec (model YAML)

In the latest YAML spec, you can define metrics on a model that has semantic modeling enabled. Add a top-level metrics list alongside semantic_model and columns (metrics are not nested under semantic_model). Type-specific settings are top-level keys on each metric.

Available metric properties (latest spec)

PropertyTypeRequiredDescription
namestringYesUnique metric name. Use lowercase letters, numbers, and underscores.
typestringYesOne of: simple, cumulative, ratio, derived, conversion.
descriptionstringNoDocumentation for the metric.
labelstringNoDisplay name in downstream tools.
filterstringNoMetricFlow filter expression (dimensions, entities, or other metrics).
configobjectNoSupports meta, group, tags, enabled.

Properties by metric type (latest spec)

Metric typeKey properties
Allname, type, description, label, hidden, filter, config
Simpleagg, expr, time_granularity, agg_time_dimension, join_to_timespine, fill_nulls_with; optionally non_additive_dimension
Derivedexpr, input_metrics (each with optional alias, filter, offset_window)
Rationumerator, denominator (each a metric name or a dict with name, filter, alias)
Conversionentity, calculation, base_metric, conversion_metric, window; optional constant_properties
Cumulativeinput_metric, window, grain_to_date, period_agg

Cross-model metrics: Metrics under a model's metrics: list can only reference that semantic model. Metrics that depend on other semantic models (for example, cross-model cumulative, ratio, derived, or conversion) go in a top-level metrics: block (outside models:). This can live in the same YAML file or a separate file.

Note: For the legacy spec, all metrics were defined in standalone YAML; there was no model-level metrics: list.

For the latest spec, refer to Semantic models. For metric types, type_params, and more examples, refer to Creating metrics.

Was this page helpful?

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

0
Loading