New: one score for how consistent your answers are. See more

Metric definitions: how to write one, 8 worked examples and a template

The fields a metric definition needs, eight SaaS and ecommerce metrics written out with the edge cases that split teams, and a copyable template.

December 1, 2026•12 min read•Vivek Sah
Jump to a section

A metric definition is the written rule behind a number: the formula, plus every small decision that changes the result. Finance and product both report churn, both use correct SQL, and the numbers still differ because one divided by customers at the start of the month and the other added the month's new signups to the denominator. Below is the anatomy of a definition that settles that kind of argument, eight common SaaS and ecommerce metrics written out field by field, a template you can copy, and the same definition written so an AI agent can use it.

What a metric definition is

A metric is a number you track: monthly recurring revenue, weekly active users, average order value. Its definition is the rule for computing it, precise enough that two analysts working separately land on the same figure.

Most published definitions stop at the formula. "Churn rate = churned customers / total customers" reads fine and leaves open which customers, counted when, in which time zone, and whether a downgrade to the free plan counts. Each open question is a place where two teams can make different calls and both be right.

A metric definition sits between two other documents. A data dictionary explains columns ("status code 3 means shipped"). A business glossary explains words ("a customer is a company with a paid plan"). The metric definition combines columns into a number and pins down every choice along the way.

The anatomy of a metric definition

These are the fields worth filling in. The middle ones (grain, time, inclusions and exclusions) are the ones most templates skip, and they cause most of the disagreements.

FieldWhat it pins downWhy it matters
NameOne identifier, e.g. mrrStops "MRR", "recurring revenue" and "run rate" from drifting into three metrics
One-line meaningWhat the number tells you, in plain wordsLets a non-analyst check it's the right metric
FormulaThe calculation in words, then in SQL or a semantic-layer referenceThe words catch logic errors the SQL hides
GrainWhat one unit is: a subscription, a customer, an order, a sessionCounting customers vs subscriptions can move churn by points
TimeSnapshot or sum over a period, the period boundaries, the time zoneAn order at 9pm New York time on January 31 is a February order in UTC
Includes / excludesStatuses, plan types, test and internal accounts, refunds, taxesWhere most "your number is wrong" threads end up
Valid dimensionsWhat it can be sliced by, and what it can't be summed acrossMRR adds up across regions; a churn rate doesn't
Source tablesThe tables and columns it readsSo the next person can rebuild it, and so schema changes can be traced
OwnersA business owner who decides, a technical owner who maintainsDisputes need someone with the authority to pick
Version and changed onVersion number, date, what changedA year-over-year chart across a definition change compares two different things
Known disagreementsWhere other teams or tools calculate it differently, and whySaves the next person from redoing the same reconciliation

A full worked example: MRR

Here is one metric with every field filled in. The company and tables are fictional; the decisions are the ones most subscription businesses end up making.

FieldDefinition
Namemrr
MeaningThe monthly value of the recurring subscriptions customers are paying for right now
FormulaSum, over paying subscriptions, of the recurring price normalized to one month, after recurring discounts. Annual plans divide by 12, quarterly by 3
GrainComputed per subscription item, reported as a total
TimeSnapshot at 23:59:59 on the last day of the month, America/New_York. Never summed across months
IncludesSubscriptions in active or past_due status
ExcludesTaxes, one-time charges and setup fees, usage-based charges, free plans, items still in trial, internal and test accounts
Valid dimensionsPlan, billing interval, region, acquisition channel. Additive across all of them
Source tablesbilling.subscriptions, billing.subscription_items, billing.discounts, crm.accounts.is_internal
OwnersBusiness: Head of Finance. Technical: data lead
Versionv2, changed 2026-07-01: recurring discounts are now subtracted. v1 used list price
Known disagreementsSales quotes ARR at contract signature, before the subscription starts. Finance's revenue figure is recognized revenue, which includes usage and one-time fees. Neither is MRR

Most of those choices have no universal answer, so write down the one you made. Stripe's Billing analytics, for comparison, counts active and past_due subscriptions, excludes taxes, free plans and metered products, counts a 600 USD annual plan as 50 USD a month, and lets each account decide whether to subtract recurring and one-time discounts. (Source: Stripe docs: Billing analytics, metric definitions, https://docs.stripe.com/billing/subscriptions/analytics, checked on 2026-12-01) If your warehouse number and the Stripe dashboard disagree, the discount setting is the first thing to check. The time zone is the second: Stripe's own docs note that its downloadable reports use UTC while its charts use the account's time zone, so monthly totals might not match exactly. (Source: Stripe docs: Billing analytics, metric definitions, https://docs.stripe.com/billing/subscriptions/analytics, checked on 2026-12-01)

Seven more metrics, and the calls that split teams

The rest are shorter: the formula, then the decisions you have to write down. Each one is a real source of "why doesn't my number match yours".

Customer (logo) churn rate

Formula: customers who churned in the period, divided by customers at risk of churning in the period.

The denominator is where teams split. "Customers at the start of the month" is the common version. Stripe divides churned subscribers in the past 30 days by active subscribers 30 days ago plus new subscribers in those 30 days, so 100 churned against 1,000 at the start and 100 new gives 9.1%, where the start-only version gives 10%. (Source: Stripe docs: Billing analytics, metric definitions, https://docs.stripe.com/billing/subscriptions/analytics, checked on 2026-12-01) Also decide:

  • When churn happens: the day they click cancel, the day the paid period ends, or the day an unpaid invoice gives up.
  • The grain: a customer with two subscriptions who cancels one hasn't churned as a customer.
  • Whether a downgrade to a free plan is churn.
  • Whether a customer who comes back within 30 days is a reactivation or was never churned.

Net revenue retention (NRR)

Formula: MRR today from the customers who were paying 12 months ago, divided by those same customers' MRR 12 months ago.

Decide whether it's a 12-month cohort figure or a monthly figure annualized (they diverge quickly in a growing business), and keep new customers out of the numerator. Revenue retention includes expansion, so it can exceed 100%; Stripe's cohort retention works the same way. (Source: Stripe docs: Billing analytics, metric definitions, https://docs.stripe.com/billing/subscriptions/analytics, checked on 2026-12-01) Multi-currency businesses also need a rule for exchange rates: today's rate for both periods, or each period's own rate.

Weekly active users (WAU)

Formula: distinct users with at least one qualifying event in the week.

"Active" is the whole definition. A login, a page view and a core action (sent a message, ran a report) give three very different numbers, and product teams often mean the third while the tracking table makes the first easiest. Then:

  • Trailing 7 days or calendar week, and if calendar, which day it starts and in which time zone.
  • Internal staff, test accounts and API bots out.
  • Users or accounts. A B2B dashboard usually wants weekly active accounts next to it.

Trial-to-paid conversion rate

Formula: trials that converted to a paid plan, divided by trials.

Which trials is the question. "Trials that started in the period" needs a conversion window and makes recent cohorts look bad until it closes. "Trials that ended in the period" is current but mixes cohorts. Stripe uses trials converted in the last 30 days over trials ended in the last 30 days, and notes the rate can exceed 100% when trials convert after the trial period ends. (Source: Stripe docs: Billing analytics, metric definitions, https://docs.stripe.com/billing/subscriptions/analytics, checked on 2026-12-01) Also decide whether a customer who starts three trials counts once or three times.

Three ecommerce metrics

MetricFormulaDecisions to write down
Average order value (AOV)Order revenue / number of ordersBefore or after discounts. Shipping and tax in or out. Refunds subtracted, or left for net revenue. Zero-value orders (replacements, 100% coupons) counted or excluded. One currency or converted
Repeat purchase rateCustomers with 2+ orders / customers with 1+ orders, in a windowLifetime or a fixed window (12 months is common). Guest checkouts matched to accounts by email or treated as new people. Cancelled orders out. Subscription renewals counted as repeat purchases or not
Conversion rateOrders / sessionsSessions or users in the denominator. Whose sessions: the store platform's or the analytics tool's, which rarely match. Bot traffic filtered. Orders counted by session date or order date

Net revenue and active customer are written out in full in the data dictionary example, next to the columns they use.

A metric definition template

Copy this into a doc or a wiki page, one block per metric. Leave a field blank rather than writing "n/a" so the gaps stay visible.

Metric:                  mrr
One-line meaning:        Monthly value of recurring subscriptions customers pay for now
Formula (words):         Sum of monthly-normalized recurring price, after recurring discounts
Formula (SQL / ref):     link to the model, saved query or semantic-layer metric
Grain:                   subscription item
Time:                    snapshot, last day of month 23:59:59, America/New_York
Includes:                active, past_due
Excludes:                taxes, one-time fees, usage charges, free plans, trials, internal accounts
Valid dimensions:        plan, interval, region, channel (additive across all)
Not valid for:           summing across months
Source tables:           billing.subscriptions, billing.subscription_items, billing.discounts
Business owner:          Head of Finance
Technical owner:         data lead
Version / changed on:    v2, 2026-07-01, now subtracts recurring discounts
Known disagreements:     Sales ARR counts at signature; finance revenue is recognized revenue
Related metrics:         arr, nrr, logo_churn_rate

If you keep definitions in a spreadsheet instead, these are the column headers:

metric,meaning,formula_words,formula_ref,grain,time_rule,includes,excludes,valid_dimensions,not_valid_for,source_tables,business_owner,technical_owner,version,changed_on,known_disagreements,related_metrics

When two teams already have two numbers

Most definitions get written after an argument, not before. A short routine turns the argument into a definition:

  1. Get both queries and run them for the same period.
  2. Diff at the row level. List the customers, orders or users counted by one query and not the other. A handful of examples explains more than the totals.
  3. Name each difference as a decision: denominator, status filter, time zone, test accounts.
  4. Have the business owner pick, one decision at a time.
  5. If both versions are useful, keep both under different names (gross_mrr and net_mrr) rather than deleting one. Plenty of disputes turn out to be two valid metrics sharing one name.
  6. Bump the version, record the changed-on date and announce it where the old number was reported.

Making the definition readable by an AI agent

When someone asks Claude or ChatGPT "what was churn last month?" against your warehouse, the model writes SQL from whatever it can see. With no definition in reach it picks a sensible formula, and a different chat on a different day can pick a different sensible formula. The fix is to put the definition where the agent reads it before writing SQL.

The usual home for a machine-readable version is a semantic layer. Here is the churn rate above in dbt's MetricFlow, written to the current spec where metrics and dimensions sit on the model itself (dbt v1.12 and later). (Source: dbt docs: Semantic models, https://docs.getdbt.com/docs/build/semantic-models, checked on 2026-12-01) The table has one row per account per month:

models:
  - name: fct_account_months
    description: One row per account per month. Month boundaries in America/New_York.
    semantic_model:
      enabled: true
    agg_time_dimension: month_start
    columns:
      - name: account_month_id
        entity:
          type: primary
          name: account_month
      - name: month_start
        granularity: month
        dimension:
          type: time
      - name: is_internal
        dimension:
          type: categorical
    metrics:
      - name: accounts_churned
        description: Accounts whose last paid subscription ended this month. Cancel date is the end of the paid period.
        type: simple
        agg: sum
        expr: case when churned_this_month then 1 else 0 end
        filter: "{{ Dimension('account_month__is_internal') }} = false"
      - name: accounts_at_risk
        description: Accounts paying at the start of the month plus accounts that became paying during it.
        type: simple
        agg: sum
        expr: case when paying_at_start or became_paying_this_month then 1 else 0 end
        filter: "{{ Dimension('account_month__is_internal') }} = false"
      - name: logo_churn_rate
        label: Logo churn rate
        description: "v2, changed 2026-07-01. Denominator includes new accounts (matches Stripe). Finance's board deck uses start-of-month accounts only."
        type: ratio
        numerator: accounts_churned
        denominator: accounts_at_risk

The ratio metric takes two other metrics as its numerator and denominator, and each can carry its own filter. (Source: dbt docs: Ratio metrics, https://docs.getdbt.com/docs/build/ratio, checked on 2026-12-01) Look at what the YAML can't hold on its own: the time zone, the cancel-date rule, the version and the disagreement with finance all live in description fields. An agent reading this metric gets the formula from the structure and the judgment calls from the text, so write the descriptions as carefully as the SQL.

Other warehouses have the same idea in their own syntax: Databricks metric views and Snowflake semantic views both declare measures, dimensions and filters in one object, and the anatomy above maps onto them field for field. If you're deciding whether you need a semantic layer at all, What is a semantic layer? covers that.

Keeping metric definitions in Contextflo

Contextflo keeps your metric definitions, business concepts and verified queries in one place on top of the warehouse you already have, and every answer your team gets in Claude or ChatGPT reads them. Save churn once with its denominator and exclusions, and the sales lead asking in ChatGPT and the founder asking in Claude get the same number.

When you connect a source (about 10 minutes), Contextflo generates table and column descriptions plus starter metric definitions from your schema, code and docs, and the definitions sharpen as your team saves corrections. Admins can see which answers cited an approved definition and which didn't, which is a quick way to find the next metric worth writing down. It works with the Claude or ChatGPT subscription your team already pays for, so one AI bill and you pick the model, and it's from $500/month for up to 10 people, unlimited queries.

Here is a more in-depth look at Contextflo and how it works.

What is Contextflo?

Contextflo is a governed context layer between your data and the AI your team already uses. Connect your warehouse once, and your team asks questions in their own Claude or ChatGPT. The model writes and runs the SQL; Contextflo supplies the definitions, the per-user access control, and the audit that make the answers trustworthy. Your data never moves, and you do not need a data team.

How it works

1
Connect your data
Point Contextflo at your warehouse or database, or upload a CSV. It reaches multiple sources at once, so a single question can span all of them.
2
Bootstrap your context layer and review
Connect your code repo, Notion docs, or a data dictionary, and Contextflo annotates each table in your data source where it can. You review and correct them. That becomes the foundational context layer: your AI agent does not just see tables, it sees the context around them.
3
Define metrics and save golden queries
Pin the verified SQL behind a metric once. Every question then resolves against the same definitions, so the number is consistent no matter who asks or how they phrase it.

Contextflo, explained by our founder.

Your team queries in their own Claude or ChatGPT over MCP, so you bring any agent rather than a locked-in bot, and every answer comes back with the SQL shown and access enforced per user.

FAQ

What is a metric definition? A metric definition is the written rule for how a number is calculated. It names the metric, gives the formula, and fixes the details that change the result, such as the grain, the time window and time zone, what is included and excluded, the source tables, the owner and the date it last changed. Two people who follow the same definition get the same number.

What should a metric definition include? At minimum a name, a one-line meaning, the formula, the grain, the time rules (period, time zone, snapshot or sum), inclusions and exclusions, the dimensions it can be sliced by, source tables, a business owner and a technical owner, a version with a changed-on date, and the known places where other teams calculate it differently.

What is the difference between a metric and a KPI? A KPI is a metric the business has chosen as a target or a headline. Every KPI is a metric, but most metrics are not KPIs. A KPI still needs a full metric definition underneath it, plus a target and a review cadence.

How do AI agents like Claude and ChatGPT use metric definitions? When Claude or ChatGPT answers a data question, it writes SQL from whatever context it can see. With no definition available it picks a reasonable formula on its own, and two chats can pick two different ones. When the definition is available at query time, as a semantic layer metric or a definition the agent reads before writing SQL, every answer uses the same formula and exclusions.

See it on your own data.

Connect your warehouse and your team can ask Claude about it the same day.

Keep reading