For the complete documentation index, see llms.txt. Markdown versions of documentation pages are available by appending .md to page URLs.
Skip to content

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: day

Parameters

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}$).

Snowflake casing convention

Vulcan doesn't enforce a casing rule on name. Mixed case passes validation on every dialect. In practice, when the underlying engine is Snowflake, use uppercase measure names (Snowflake's own convention for unquoted identifiers). For every other engine, use lowercase.

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.

For ratio, any authored measure_refs are ignored. Vulcan fills it automatically as [numerator, denominator]. Query the two parts separately at the target grain and divide; averaging a pre-computed ratio across buckets produces the wrong answer.

behaviour and semantic_config are accepted as deprecated aliases for behavior on YAML load. Vulcan logs a warning and treats them as behavior. Combining behavior with either alias, or using both aliases at once, is a validation error. Use behavior in new YAML.

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:

  • name is not a valid identifier, or is the reserved word count

  • type is unrecognized

  • type is not count and expression is empty

  • filters is set on a type that doesn't allow it, or type: number is combined with filters

  • Any filters entry is empty

  • A column reference in expression/filters isn't the canonical {model}.column or bare column form, or the expression contains a subquery, CTE, lateral join, or column alias (logged as a warning by default; hard-fails when strict_semantic_validation: true)

  • type is string, time, or boolean and the expression body doesn't contain an aggregate function (same warn-by-default / hard-fail-when-strict behavior)

  • behavior sets required or forbidden fields incorrectly for its declared type

  • name is not unique within the semantic model

Last updated

Was this helpful?