9. Semantic layers and metrics
A semantic layer sits between the data and every tool that reads it, and defines each business measure once: its formula, how it adds up, and which dimensions it may be cut by. Every report then asks the layer, and gets the same number.
The clip draws three layers. At the bottom, the tables: the claim and premium facts and their dimensions. In the middle, the semantic layer: the measures incurred claims, earned premium and the loss ratio, each defined once, with the dimensions they may be cut by. At the top, the readers: the board pack, the claims dashboard, a spreadsheet and an AI assistant, all asking the layer. Then the trap: the loss ratio of each product line from the seed, their average, and the ratio of the totals. The average is a different number; only the ratio of the totals matches finance.
The intuition: the definition lives in one place
Harbour Mutual's board pack and the claims team's dashboard both show the 2024 loss ratio, and they disagree. Neither is broken. The board pack divides total incurred claims by total earned premium; the dashboard works out each product line's ratio and averages the three. Each tool holds its own formula, written by a different analyst.
The fix is not to correct one report. It is to take the formula out of the reports altogether and keep it in one place that every report asks. Then the board pack, the dashboard, a spreadsheet and the AI assistant all get the loss ratio from the same definition, and a change to the definition reaches all of them at once.
That place is a semantic layer: a model, between the tables and the tools, that turns columns into business measures and dimensions with business names. Readers ask for "loss ratio by product line for 2024"; the layer knows which tables to join, what to sum and in which order to divide.
The theory: measures, additivity and the layer
A measure (or metric) is a number the business tracks, defined by: a name from the glossary; an expression over the data (the sum of incurred amounts); an aggregation rule (sum, count, distinct count, average, last value); the filters that always apply (only claims whose loss falls in the period); the dimensions it may be grouped and filtered by (year, product line, country, loss cause); its time grain; and an owner. A dimension in the layer is an attribute readers group by, often arranged in a hierarchy (year, quarter, month).
Measures differ in how they add up, the same distinction as for facts (page 6). An additive measure can be summed across every dimension: incurred claims for the year is the sum of the months, the lines and the countries. A semi-additive measure adds across some dimensions but not time: the number of open claims at month end adds across lines, but not across months; across time it takes the last value. A non-additive measure cannot be summed at all: ratios, averages, percentages and distinct counts.
Harbour Mutual's seed shows the gap. The board pack's ratio of the totals for 2024 is 66.1%; the average of the three product lines' ratios is 65.6%. Same data, two formulas, two numbers. The semantic layer makes the first the only definition, and the claims team's view a filter on it.
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_lineWhere semantic layers live. The idea is old: business intelligence tools have long had a metadata layer of business names over tables. Today it appears in three forms. Inside a BI tool, such as a Power BI or Fabric semantic model with its measures written in DAX. As a headless or universal layer outside any one tool, which BI tools, notebooks and applications all query, such as dbt's semantic layer, Cube or LookML. And as metric definitions in a catalogue. The choice is about reach: a layer inside one tool only serves that tool's readers.
A semantic layer rests on a dimensional model. Conformed dimensions (page 6) are what let a measure from claims and a measure from premiums be cut by the same product line and divided. A layer built on tables with mixed grains or unconformed keys gives consistent wrong answers.
Why it matters
Most of the distrust in Harbour Mutual's numbers comes from formulas copied into reports. Every copy is a chance to differ. A semantic layer turns "which loss ratio is right?" from a monthly argument into a question of which definition the layer holds, and who owns it.
AI assistants make this urgent. An assistant that writes its own SQL will choose a formula; an assistant that asks the semantic layer gets the governed one. Chapter 34 shows the difference.
Where it goes wrong
- Averages of ratios. The most common wrong number in business reporting: compute the ratio from totals, for each slice.
- Summing semi-additive measures over time. Twelve month-end open-claim counts added together are not a year.
- A layer per tool. One definition in the BI tool, another in the spreadsheet model and a third in the data science notebook is three definitions again.
- A layer without owners. Measures added by anyone, never reviewed, become a long list of near-duplicates.
- Logic leaking back. Report authors who override the layer's measure with their own calculation bring the disagreement back.
Check yourself
Choose an answer to each question, then press Check.
Sources
The works this page draws on, summarised in its own words rather than quoted. Read them for the full argument.
- R. Kimball and M. Ross, The Data Warehouse Toolkit, 3rd edition (Wiley, 2013)Additive, semi-additive and non-additive facts, and conformed dimensions as the basis for comparing measures.
- Microsoft Learn, Power BI and Fabric semantic modelsMeasures defined once in a semantic model, and the DAX that defines them.
- dbt Labs, the dbt Semantic Layer and MetricFlow documentationA headless semantic layer: metrics defined in code, outside any one BI tool, with their aggregation and dimensions.
Practise it
The chapters that put this theory to work on Harbour Mutual and Kestrel:
- Chapter 2: The problems it solves
- Chapter 9: Semantic models: one number, defined once
- Chapter 34: AI-ready information foundations
- Chapter 41: Stage 4: Trusted numbers
The tools to try it in:
- Lineage explorer · Trace a number back to its sources, or a change forward to everything it breaks.
Terms taught here: Loss ratioSemantic modelMeasureSemi-additive measure