Overview
A metric is a function of dimensions
A metric on its own is a single number. The interesting questions slice it: revenue by region, by product line, by week. Three knobs every metric exposes:
- Dimension — the discrete grouping column (
region,channel,plan_tier). - Grain — the minimum row identity of the underlying fact (
one row per order,one row per session). - Time — a special, ordered dimension with rules of its own (
day,week starting Monday,fiscal quarter).
Why time is special
- Cumulative metrics, lag/lead, period-over-period comparisons all depend on a consistent time grain.
- Time zones and week-starts are a notorious silent bug source:
WEEK(order_ts)returns different values in BigQuery, Snowflake and Postgres unless you pin the start day. - Slowly Changing Dimensions (SCDs) interact with time:
revenue by customer_segment by monthonly makes sense if you pick as-of semantics (segment at order time vs segment today).
The semantic layer pins these decisions in one file. Every consumer that asks for revenue BY week gets the same Monday-anchored ISO week, every time.