Level 1: Model the data

Metric contracts

Self-service needs a contract, not a license.

Licenses give people access. A metric contract tells them which number is official, what it means, and what it does when the data is missing.

Updated November 2026Example data, not from a client.
On this page
  1. Licenses aren't the hard part
  2. The one-page contract
  3. The three empty cases
  4. Lock the official measures
  5. What I check

Most self-service rollouts start with licenses and a training session. A few months later there are four versions of revenue, each one built by someone trying to help. None of them is malicious. They just weren't told which number is official, or what it means.

Licenses aren't the hard part

A license gives someone access to the data. It doesn't tell them which measure to use, which date it runs on, or what an empty cell means. So people work it out, and each of them works it out a little differently.

What makes self-service work is a contract: a short, written agreement for each official measure. What it answers, which date it uses, what it does when data is missing, and who's allowed to change it. People build whatever they like on top. The contract stays put.

Figure 1 · Written, locked, open

Self-service on a contract: written, locked, open Three layers. The metric contract is written: definition, date rule, empty cases and owner. The official model is locked: it holds the contract measures and is endorsed as certified. Self-service reports are open: a sales view, a finance view and ad hoc reports are built on top. Anyone builds on top, and nobody edits the official measures. Metric contract Definition, date rule, empty cases, owner WRITTEN Official model Contract measures, endorsed as certified LOCKED Self-service reports OPEN Sales view Finance view Ad hoc Anyone builds on top. Nobody edits the official measures.
The contract is the top layer. Reports change every week. The definitions under them don't. Open full size

The one-page contract

Here's mine for the measure from guide 1. It fits on one page, and every line is something I've seen go wrong when it was missing.

measure: Net Revenue (reporting date)
answers: Recognized revenue for a period,
  by reporting date
owner: A named person in finance reporting
status: Approved, version 1.0
source: Revenue. One row per recognized
  revenue entry.
date_rule: Reporting date. Start
  inclusive, end exclusive.
required: A period. There is no default
  period.
not_this: Not accounting-date revenue.
  Not a term amount.
no_rows: "No records". Never 0.00.
zero: 0.00, complete
unknown_date: Withhold the total. Say how
  many rows have no date.
reference:
  April 2025, C-001, P-01 = 100.00
  All of 2025, C-001, P-01 = 400.00
changes: Owner approves. Reference
  answers rerun first.

Two lines matter more than they look. "There is no default period" stops a tool from quietly answering for all time when someone forgets to ask for April. That's the 400.00 from guide 1. And the reference answers turn the contract into something you can test, not just something you can read.

The three empty cases

The contract says no rows, a zero and an unknown date give three different results. To show them, I add two obviously made-up rows to the example: R-004, a June entry of 0.00, and R-005, an entry of 50.00 with no reporting date. Each case is run on its own.

Figure 2 · Three empty cases

The three empty cases: no rows, a zero and an unknown date Three cases for C-001, P-01, each with a different answer. No rows: July 2025 returns No records, not 0.00. A zero: June 2025 with a made-up entry R-004 of 0.00 returns 0.00, complete. Unknown date: April 2025 with a made-up undated entry R-005 is withheld, because R-005 could belong to April. THREE EMPTY CASES Three different answers, not three blanks NO ROWS No records July 2025 Not 0.00. Nothing was there to add. A ZERO 0.00 June 2025, with R-004 = 0.00 Complete. A real entry that nets to zero. UNKNOWN DATE Withheld April 2025, with R-005 undated R-005 could be April. Say so.
A blank cell can mean any of these. The contract makes the report say which. Open full size

This query returns a status with the amount. As written, it asks for April. Change the two dates to ask for another month.

SELECT
  CASE
    WHEN SUM(CASE
        WHEN reporting_date IS NULL
        THEN 1 ELSE 0 END) > 0
      THEN 'Withheld: unknown date'
    WHEN SUM(CASE
        WHEN reporting_date >= '2025-04-01'
         AND reporting_date <  '2025-05-01'
        THEN 1 ELSE 0 END) = 0
      THEN 'No records'
    ELSE 'Complete'
  END AS status,
  CASE
    WHEN SUM(CASE
        WHEN reporting_date IS NULL
        THEN 1 ELSE 0 END) > 0
      THEN NULL
    ELSE SUM(CASE
        WHEN reporting_date >= '2025-04-01'
         AND reporting_date <  '2025-05-01'
        THEN amount END)
  END AS amount
FROM revenue
WHERE customer = 'C-001'
  AND product = 'P-01';

On the base data it returns Complete, 100.00. For July it returns No records with no amount. For June, with R-004 added, it returns Complete, 0.00. For April, with R-005 added, it returns Withheld: unknown date, because R-005 could belong to April and there's no way to prove it doesn't.

In Power BI, a status measure next to the value does the same job:

Revenue Status =
VAR UnknownDates =
    CALCULATE (
        COUNTROWS ( Revenue ),
        ISBLANK ( Revenue[Reporting Date] ),
        REMOVEFILTERS ( 'Date' )
    )
VAR RowsInPeriod = COUNTROWS ( Revenue )
RETURN
    SWITCH (
        TRUE (),
        UnknownDates > 0,
            "Withheld: unknown date",
        RowsInPeriod = 0, "No records",
        "Complete"
    )

Lock the official measures

In Power BI, locking usually means one shared semantic model with the contract measures in it, endorsed as certified. People get Build permission and make their own reports on top. They can add measures in their own reports, but they can't change the official ones, and the official names stay official.

In dbt, the semantic layer's metrics play the same role: defined once in code, reviewed like code. The tool matters less than the rule. One definition, one owner, and reference answers that rerun before every change.

What the contract gives an AI tool

The same contract is the best context you can give a tool that answers questions from the model. It says which measure answers "revenue", which date it uses unless someone asks for another, that a period is required, and what to say when the answer is withheld. Without it, the tool fills each of those gaps on its own, and it won't tell you it did.

It also gives you a way to check the tool. Ask it the reference questions. If it doesn't return 100.00 for April and 400.00 for 2025, the problem shows up before anyone relies on it.

What I check before any tool answers from a model

  1. Does every official measure have a contract with an owner and reference answers?
  2. Are no rows, a zero and an unknown date three different results?
  3. Can self-service users build on the official measures without being able to change them?
  4. Do the reference answers rerun before every release?

Give people the license. Give the numbers a contract.

Building this in Power BI?

The Professional Harness gives your coding agent working PBIP examples and checks it reruns until they pass.

See the Professional Harness

Privacy

Related