9. Semantic models: one number, defined once
Two reports can compute the same number from the same data and disagree. A semantic model defines each measure once, with the dimensions it can be cut by, and every report reuses that definition.
The clip shows two reports for the same year. The board pack divides total incurred claims by total earned premium; the claims team's dashboard averages the loss ratios of the three product lines, and shows a different number. The clip shows why: in an average, a small line weighs as much as a large one. Then a semantic model defines the three measures once (incurred claims, earned premium and the loss ratio), with their dimensions and grain, and both reports show finance's figure. Last, the Azure form: a Power BI semantic model, and a Fabric semantic model in Direct Lake mode.
The idea: define the number where every report can reuse it
Chapter 2 found three definitions of premium. Even with the definition agreed, a number can still come out differently, because each report computes it its own way. A ratio is the classic trap: the loss ratio of a year is not the average of the loss ratios of its parts. You add up the claims, add up the premium, and divide once.
A semantic model is the layer between the tables and the reports that holds those definitions once. It has three things:
- Measures: the numbers, each defined once (incurred claims, earned premium, the loss ratio).
- Dimensions: what the numbers can be cut by (year, product line, country, loss cause).
- Grain: what one row of each fact means (one claim; one premium instalment), so the measures add up correctly.
A report then asks for "the loss ratio, by product line" and the semantic model computes it, totals first, for whatever the report shows. Two reports that use the measure cannot disagree.
A worked example: the board pack and the claims team's dashboard
For 2024, the board pack shows a loss ratio of 66.1%: incurred claims of €105,600 divided by earned premium of €159,833. The claims team's dashboard shows 65.6%, because it averages the three product lines' ratios.
| Product line | Incurred claims | Earned premium | Loss ratio |
|---|---|---|---|
home | €50,450 | €70,797 | 71.3% |
motor | €27,650 | €49,634 | 55.7% |
travel | €27,500 | €39,402 | 69.8% |
Both numbers come from the same rows. The query below computes the two of them on Harbour Mutual's tables, and the lab runs it on PostgreSQL 18.3 in its checks: the measures' definitions, by product line, then the two ways of combining them.
WITH by_line AS (
WITH instalments AS (
SELECT policy_id, amount, due_date AS starts, CAST(due_date + INTERVAL '6 months' AS DATE) - 1 AS ends
FROM premium_transactions
), earned AS (
SELECT pr.line, SUM(i.amount * (LEAST(i.ends, DATE '2024-12-31') - GREATEST(i.starts, DATE '2024-01-01') + 1) / (i.ends - i.starts + 1)) AS earned
FROM instalments i
JOIN policies p ON p.policy_id = i.policy_id
JOIN products pr ON pr.product_id = p.product_id
WHERE i.starts <= DATE '2024-12-31' AND i.ends >= DATE '2024-01-01'
GROUP BY pr.line
), incurred AS (
SELECT pr.line, SUM(c.reserve + COALESCE(pay.paid, 0)) AS incurred
FROM claims c
JOIN policies p ON p.policy_id = c.policy_id
JOIN products pr ON pr.product_id = p.product_id
LEFT JOIN (SELECT claim_id, SUM(amount) AS paid FROM claim_payments GROUP BY claim_id) pay ON pay.claim_id = c.claim_id
WHERE c.loss_date BETWEEN DATE '2024-01-01' AND DATE '2024-12-31'
GROUP BY pr.line
)
SELECT e.line, COALESCE(i.incurred, 0) AS incurred_claims, ROUND(e.earned, 0) AS earned_premium,
ROUND(COALESCE(i.incurred, 0) / ROUND(e.earned, 0), 4) AS loss_ratio
FROM earned e
LEFT JOIN incurred i ON i.line = e.line
ORDER BY e.line
)
SELECT ROUND(SUM(incurred_claims) / SUM(earned_premium), 4) AS board_pack_loss_ratio,
ROUND(AVG(incurred_claims / earned_premium), 4) AS average_of_lines
FROM by_lineIn the semantic model, the board's three measures are defined once, as a Power BI semantic model would hold them:
| Measure | Definition | In DAX |
|---|---|---|
| Incurred claims | Paid plus still reserved, for claims whose loss happened in the period. | Incurred claims = SUM ( fact_claim[incurred_amount] ) |
| Earned premium | The premium for the days of cover in the period, instalment by instalment. | Earned premium = SUM ( fact_premium[earned_premium] ) |
| Loss ratio | Incurred claims divided by earned premium, each totalled first for whatever is being looked at. | Loss ratio = DIVIDE ( [Incurred claims], [Earned premium] ) |
Why it matters for Alex
Alex knows Power BI from the inside, and knows that every team builds its own model with its own measures because it is quicker. That is how the board ended up with two loss ratios. As architect, Alex's job is to make one certified semantic model the easy choice: the definitions agreed with finance, the grain written down, and every report built on it.
When Kestrel's reports arrive with their own schadequote, the question is not whose number is right but which definition the board signed off, and whether Kestrel's data can feed the same measures.
Where it goes wrong
- A model per report. Fifty reports with fifty copies of "loss ratio" give fifty chances to differ.
- Storing the ratio. A loss_ratio column per row is right for that row only; summing or averaging it gives a wrong total.
- No grain written down. Joining claims to premium instalments without saying what one row means counts premium twice.
- Definitions nobody signed off. A measure the data team chose is still a guess until the business owner agrees it (chapter 21).
Exercises
The lab checks each one against facts written down in advance, so any answer the brief allows passes. A pass is kept in this browser.
Define the board's three measures
Finance has reconciled the year to the ledger. For each of the board's measures, choose the definition that gives finance's figure.
Measure or dimension?
For each part of the board's semantic model, choose whether it is a measure or a dimension.
Choose where the definition lives
Where should the loss ratio be defined for this brief: in each report, once in a semantic model, or as a stored column in the warehouse? Pass all 3 situations to complete it.
The board pack, finance's monthly report and the claims team's dashboard all show the loss ratio: for the year, by product line and by country. They must agree with finance's figures.
On Azure
On Azure, the semantic model is a Power BI semantic model (the name for what Power BI used to call a dataset):
- Measures are written in DAX, as in the table above; relationships carry the cardinality of chapter 6, and the model's tables set the grain.
- Storage: in Import mode the data is copied into the model on a schedule; in DirectQuery mode each visual queries the source. In Microsoft Fabric, Direct Lake mode reads the Delta tables of a lakehouse or warehouse in OneLake directly, without importing a copy.
- One model, many reports: publish the model once, endorse it as certified so people know it is the one to use, and build reports on it with a live connection instead of copying its measures.
- Under source control: Power BI Desktop can save a model as a Power BI Project, with the model in TMDL text files that Git can compare and review.
Microsoft Purview can show the semantic model in the lineage from source tables to reports, and its glossary can hold the definition the measure implements (chapters 12 and 13).
Take it to work
Measure definition
Define one measure so that every report computes it the same way.
The measure
- Its name, and its definition in one sentence
- Who signs it off?
The calculation
- Which facts, which filters, and how is it combined: summed, or totals first, then divided?
- Its grain: what one row of each fact means
The dimensions
- What may it be cut by, and what not?
The proof
- Which figure from finance does it reproduce, for which period?
Tools in this chapter
- Lineage explorer · Trace a number back to its sources, or a change forward to everything it breaks.
Terms taught here: Semantic modelMeasure