Measures
Define semantic model aggregations, measure types, filters, semantic behavior, and rolling windows.
You can use the measures parameter within a semantic model to define measures. Each measure is an aggregation over a column of the underlying physical model, referenced with {name.column} syntax, where name is the semantic model name.
Every measure requires name and type. Every type except count also requires expression.
measures:
- name: total_users
type: count
expression: "{users.user_id}"
description: Total registered users
- name: active_users
type: count
filters:
- "{users.status} = 'active'"
- name: avg_mrr_per_account
type: avg
expression: "{subscriptions.mrr}"
filters:
- "{subscriptions.status} = 'active'"
behavior:
type: stock
time_dimension: start_date
period_treatment: avg
period_grain: dayParameters
Every field a measure supports, one section per key.
name
The identifier of a measure. Must be unique among measures within a semantic model and follow the naming rules (^[a-zA-Z_][a-zA-Z0-9_]{0,63}$).
description
Human-readable explanation of what the measure represents. Optional; defaults to an empty string.
public
Controls whether the measure is exposed to consumers. Defaults to true.
tags
Categorization labels for the measure. Validated against ^[a-zA-Z0-9.:_-]+$ and normalized to lowercase.
terms
Business glossary references for the measure, typically dotted FQNs. Validated against ^[a-zA-Z0-9._-]+$ and normalized to lowercase.
ai_context
Structured hints for AI/LLM consumers on this measure: instructions, synonyms, caveats, and worked examples. See AI context for the full field reference.
expression
A SQL-ish definition of the measure, written with {name.column} references. Required for every type except count; declaring a non-count measure with an empty expression fails validation ("requires a non-empty expression").
expression is not limited to a single {name.column} reference. type: number, string, time, and boolean measures accept an arbitrary SQL-ish expression combining multiple references:
type
The aggregation kind. Required; must be one of the values below (normalized to lowercase on load). A measure has exactly one type.
Type
Description
expression required?
count
Row count
No. Omit it, or set it explicitly (e.g. "*" or a {name.column} ref to count non-null values)
count_distinct
Distinct count
Yes
count_distinct_approx
Approximate distinct count
Yes
sum
Sum aggregation
Yes
avg
Average aggregation
Yes
min
Minimum value
Yes
max
Maximum value
Yes
number
Custom numeric expression
Yes
string
Custom string expression
Yes
time
Custom time expression
Yes
boolean
Custom boolean expression
Yes
filters
A list of predicate strings, written with {name.column} references, applied when computing the measure. Optional; every entry must be non-empty.
behavior
Semantic classification of how the measure should be queried and aggregated. Optional. When set, behavior.type selects which sibling fields apply. is_additive is always computed from type; never author it.
behavior.type
Meaning
Additive?
Required siblings
Forbidden siblings
simple
Standard additive measure (counts, sums); safe to group and aggregate freely
Yes
None
time_dimension, period_treatment, period_grain, numerator, denominator, measure_refs
flow
In-period total (signups, orders); additive like simple
Yes
None
Same as simple
stock
Point-in-time level (MRR, active customers, headcount); do not sum across time
No
time_dimension, period_treatment, period_grain
numerator, denominator, measure_refs
ratio
Numerator ÷ denominator at the query grain
No
numerator, denominator
time_dimension, period_treatment, period_grain
derived
Composed from other measures listed in measure_refs
No
measure_refs
time_dimension, period_treatment, period_grain, numerator, denominator
period_treatment (for stock) is one of last (end-of-period snapshot), avg (average over the period), or first (start-of-period snapshot). period_grain is a time granularity such as day, week, month, or year. time_dimension must name a dimension declared on the same semantic model.
rolling_window
Computes the measure over a sliding time window instead of the query's own grain, for example a trailing 7 days or a trailing 1 month.
All three sub-fields are optional.
offset
Sets the anchor point of the window: start or end. Defaults to end.
trailing and leading
trailing sizes the part of the window before the offset point, and leading sizes the part after it. Both default to unset (zero-width) and share the same grammar: unbounded, or a duration matching -?\d+ (minute|hour|day|week|month|year)s?, for example 1 day, 30 days, -7 days. Use trailing alone for look-backs, leading alone for look-aheads, and both together for centered windows.
Here's an unbounded window used for a cumulative count:
Validation
Vulcan rejects a measure YAML block when:
nameis not a valid identifier, or is the reserved wordcounttypeis unrecognizedtypeis notcountandexpressionis emptyfiltersis set on a type that doesn't allow it, ortype: numberis combined withfiltersAny
filtersentry is emptyA column reference in
expression/filtersisn't the canonical{model}.columnor barecolumnform, or the expression contains a subquery, CTE, lateral join, or column alias (logged as a warning by default; hard-fails whenstrict_semantic_validation: true)typeisstring,time, orbooleanand theexpressionbody doesn't contain an aggregate function (same warn-by-default / hard-fail-when-strict behavior)behaviorsets required or forbidden fields incorrectly for its declaredtypenameis not unique within the semantic model
Related pages
Semantic models for how a measure fits into the full spec
Segments for reusable filters that pair with measures
AI context for adding AI/LLM guidance to a measure
Last updated
Was this helpful?