Business Metrics
Intermediate 15 min read Business Metrics

Metric Definitions That Scale

Write the recipe once; let everyone use it

Scalable metric definitions are written once, tested, versioned and owned in a semantic layer — so one shared definition can power every dashboard without forking.

metric definitionsemantic layerdefinition grammarmetric testingversioning
Prerequisites: What Are Metrics?
Before we start

What you will learn

  • Structure a metric definition: measure, dimensions, filters, grain
  • Make definitions testable and versioned
  • Design metrics that compose into KPIs and time comparisons
Introduction

What is this?

A scalable metric definition survives growth: it is written once in a shared, versioned semantic layer, structured as measure + dimensions + filters + grain, validated by tests, and owned by a human. Because it composes (into comparisons, rollups and targets), teams get consistency without duplicating logic.

Motivation

Why do you need it?

  • Spreadsheet-era habits (define it again in each workbook) do not survive 20 dashboards.
  • Composable definitions enable self-service without turning users loose on raw data.
  • Versioned definitions make changes auditable — you can see why a number moved.
  • Tests catch the classic 'it worked locally' definition bugs before they hit production.
Think about it

Mental model

Imagine

A shared library of library functions

Think of

A scalable metric catalog

You don't rewrite sort() per application; you import the tested, versioned one. Metrics are the functions of the business — write and test them once, import everywhere, upgrade in tandem.

Mechanics

How it works

  • The definition declares the numerator measure, the population (denominator scope), the allowed dimensions and the mandatory filters.
  • It specifies grain (per-order, per-day, per-user) and an as-of rule (event time vs processed time).
  • It composes: base metrics (revenue) feed derived metrics (revenue per user) and KPIs (vs target).
  • Tests assert known values, null behavior, and grain stability on every change.
  • Versioning stores the definition history, and the catalog records owner and certification.

A composable metric definition.

Measure
Dimensions
Filters
Grain + as-of
Derived + KPI
Real world

In production

  • A metrics catalog defines revenue once; finance, sales ops and exec dashboards all reference it, and a change is versioned with a reviewer.
  • A KPI library composes base metrics into retention cohorts and weekly targets without duplicating base calculations.
  • CI tests validate the metric against a fixture dataset on every merge, so a 'quick edit' can't silently change headline numbers.
Guidelines

Best practices

  • Write definitions as data (name, formula, scope, owner), not as prose to be re-implemented.
  • Version every change and require a test that asserts a known value.
  • Compose from base metrics; avoid re-deriving a base metric inside a KPI.
  • Document as-of timing and currency/timezone assumptions in the definition.
Watch out

Common mistakes

  • Copy-pasting metric expressions into each report 'temporarily' — the permanent fork.
  • Versioning the dashboard but not the metric, so rollbacks are impossible.
  • No tests: a renamed column silently changes a headline number.
  • Defining metrics in tools that can't be version-committed (some GUI-only setups).
Root cause analysis

Common issues

Error
Headline revenue changed after a 'refactor'
Root cause

A shared definition was edited without tests catching the filter change

Fix

Require review + a known-value test on every semantic definition change.

Error
New dashboard can't compose existing metrics
Root cause

Definitions hard-coded dimensions/filters inside formulas

Fix

Parameterize by dimensions and filters so metrics compose.

When things break

Debugging tips

  • When a metric moves unexpectedly, diff the definition history first, then the data.
  • Test at the seam: assert the metric against a tiny fixture where you know the answer.
  • Check composability — if a KPI doubled because it recomputed a base metric with a new filter, that's the bug.
Interviews

Interview checkpoint

Test yourself

Quick quiz

0/2
1

Which practice best prevents metric definitions from forking across teams?

2

A composite KPI should re-derive its base metric every time to stay 'fresh'.

Go deeper

Official documentation