Contents

Data Engineering › Serving & Analytics

Metric Definitions

Precisely defining what a number means, so two dashboards don't disagree.

Also known as: metrics definitions, KPI definitions, metric definition, single source of truth for metrics, metrics layer

Two dashboards both say “monthly active users”, and they show different numbers. The usual cause is that nobody wrote down exactly what the metric means, so each dashboard computed its own version.

A proper metric definition pins down everything that affects the number:

ElementExample for “Monthly Active Users”
Name and purposeMAU: how many people use the product in a month
FormulaCount of distinct user_id with at least one qualifying event in the calendar month
Qualifying eventsLogins and actions, excluding automated and background events
FiltersExclude test accounts, employees and bots
Grain / dimensionsBy month; can be sliced by country and plan
Time rulesCalendar month in UTC; late events up to 3 days are included
Sourceanalytics.fct_user_events
OwnerProduct analytics
SELECT DATE_TRUNC('month', event_time) AS month,
       COUNT(DISTINCT user_id)         AS mau
FROM analytics.fct_user_events
WHERE is_qualifying_event
  AND NOT is_internal_user
GROUP BY 1;

Where disagreements come from

  • Different filters (are refunds included? test users?).
  • Different time boundaries (UTC vs local time, event time vs processing time).
  • Different grain or double counting from a join.
  • Different sources (app database vs billing system).
  • Different definitions of the same word (“revenue”: booked, recognized or collected?).

Good practice

  • Define it once, in one place, in code, and reuse it. That’s the idea behind a semantic layer (semantic layer): metrics defined centrally and consumed by every dashboard and tool.
  • Write it in business language and as exact logic.
  • Version it and announce changes. Changing a definition changes history, so say when and why, and consider keeping old and new side by side for a while.
  • Give every metric an owner.
  • Document known quirks (data dictionary).
  • When two numbers disagree, compare the definitions first, then the data (metric discrepancy).

A metric isn’t a number. It’s an agreement about what to count.