Semantic models and business metrics

A semantic model defines how source records become business measures. It specifies the grain, relationships, time rules and calculations behind each metric.

Issued amount and unsettled balance

A calculation using one invoice, a settlement and a credit.

Example invoice: inv_1042

Amounts in GBP

Issued amountInvoice value before settlement
12,400
Posted settlementAllocated to this invoice
4,000
Allocated creditReduces the amount still due
600

The balance is calculated in GBP, with the allocated credit deducted from the amount due. Tax, foreign exchange and later adjustments are excluded.

What was invoiced?

12,400 GBPIssued amount
12,400

The issued invoice value, independent of subsequent settlement.

What remains due?

7,800 GBPUnsettled balance
12,400 − 4,000 − 600

Issued value less the posted settlement and allocated credit.

Definition ownerFinance

Specify the meaning before the formula

Consider outstanding invoice value. The definition must explain whether tax is included, how partial settlements are handled, which statuses qualify, and whether credit notes reduce the balance. A SQL sum alone cannot answer those questions. Document the business owner and the effective date of the definition with the calculation.

Separate additive measures from ratios and balances. An invoice amount can often be added across records in a compatible currency, while a month end balance should not be summed across snapshots. A percentage needs its numerator and denominator preserved so rollups recompute the ratio instead of averaging percentages blindly.

Protect measures from join multiplication

Declare the grain and cardinality of every relationship. Joining an invoice to three approval records can triple its amount unless the query first reduces approvals to the intended grain. Verify the expected number of rows and use fixtures that include multiple related records; a test with one row in each table cannot reveal this error.

Currency adds another semantic boundary. Keep transaction currency and converted reporting currency distinct. Record the exchange rate source, rate date, and rounding rule. Do not sum unrelated currencies merely because their numeric types match. The right conversion method depends on the financial question being answered.

MeasureAggregation ruleCritical constraint
Invoice amountSum compatible valuesAvoid duplicate invoice grain
Approval rateRecompute numerator divided by denominatorDefine eligible decisions
Period closing balanceSelect the relevant snapshotDo not sum across time

Make time zones and effective dates visible

Define which time controls a period: issue time, posting time, settlement time, or observation time. A business day in one region can cross two UTC dates. Store unambiguous instants and apply the relevant business calendar deliberately rather than relying on a server default time zone.

Historical analysis may require the classification that applied when a transaction occurred rather than the classification used today. If a supplier changes region or category, decide whether reports should restate history. Versioned dimension records and effective intervals can preserve that distinction, provided overlapping intervals and gaps are checked.

Version and reconcile metric definitions

Treat a metric change as an interface change. Adding an optional descriptive field differs from changing what qualifies as an approved invoice. Publish the reason, affected consumers, and reconciliation examples before switching the definition. Keep the previous calculation available long enough to explain expected differences.

Test rules such as total allocations not exceeding invoice value and balance movements reconciling to source transactions. Store lineage from each measure to its input datasets and transformation version so a discrepancy can be traced to the records and calculation that produced it.

References