Semantic models and metric definitions

Explore metric definitions, entity relationships, analytical grain and the rules behind trustworthy comparisons.

A semantic model makes the business meaning of analytical data explicit. It describes entities, relationships, measures and the dimensions through which people ask questions. Its purpose is to keep a familiar term from acquiring a different calculation in every dashboard or report.

The dbt Semantic Layer documentation provides one public example of centrally defined metrics. The principles below are useful when discussing Covorg’s governed analysis and reporting capabilities. They do not imply a particular implementation or named product integration.

Start with entities and analytical grain

The grain states what one row represents: an order, an order line, a daily product balance or a single event. Measures are only meaningful when their grain is understood. An order amount repeated across several line records cannot be summed as though every repetition were a different order.

Define entity keys and relationship cardinality before allowing flexible joins. A customer can have many orders, and an order can have several shipments. Combining both without controlling the relationship can multiply records and inflate amounts while producing a technically valid query.

Give each metric a complete contract

A definition should include the eligible population, aggregation rule, time basis, currency convention and exclusions. Terms such as revenue or active customer often have several legitimate interpretations. Choose a specific name and definition for each instead of forcing different questions into one ambiguous measure.

Contract elementWhat it clarifiesExample
PopulationWhich records qualifyAccepted orders excluding test activity
AggregationHow values combineSum of eligible order value
Time basisWhich event assigns the periodOrder acceptance time
DimensionsWhich breakdowns are validChannel and product category
Exceptional casesHow missing or undefined results appearNo eligible orders produces an undefined average
A shared business measure needs an agreed population, time basis, calculation and treatment of exceptional cases.

Aggregate ratios from their components

An average of subgroup rates can give each subgroup equal weight even when their populations differ greatly. Where the intended overall measure is a ratio, aggregate the numerator and denominator first, then calculate the result. Keep a zero denominator distinct from a genuine zero outcome.

The example contract below defines average order value. It explains the metric structure rather than prescribing a vendor configuration. The eligible amount and count still need their own approved definitions, including currency treatment and how cancellations or corrections affect the population.

Example
{
  "metric": "average_order_value",
  "grain": "one eligible order",
  "numerator": "sum of eligible order value",
  "denominator": "count of eligible orders",
  "timeBasis": "order acceptance time",
  "zeroDenominator": "undefined"
}

Manage definitions as shared dependencies

A changed eligibility rule can affect reports, alerts, forecasts and historical comparisons. Give each material definition change a version, effective date and owner. Compare representative outputs before publication and identify dependent analytical assets through lineage.

The semantic model should also expose limits. Some dimensions are inappropriate for a measure, some historical periods lack required fields and some views contain provisional information. Making these conditions explicit helps both human analysts and generated summaries avoid apparently precise but misleading answers.

Metric definition and approval

  1. 01

    Define

    Agree the business question, grain and eligible population.

  2. 02

    Model

    Specify entities, relationships, calculation and exceptional cases.

  3. 03

    Validate

    Compare representative results with source evidence and business expectations.

  4. 04

    Govern

    Publish an owned definition and review the impact of later changes.

Design considerations

  • Test joins that combine several relationships with many records on either side.
  • Keep ratios, counts and additive amounts distinguishable in aggregation rules.
  • Document the interpretation of missing information and undefined calculations.

Sources

The following sources explain the underlying technical patterns.

  1. dbt LabsThe dbt Semantic LayerOpens in a new tab
  2. OpenLineageThe OpenLineage object modelOpens in a new tab
  3. JSON SchemaUnderstanding object validationOpens in a new tab

Image details

100%

Zoom in to inspect details