Resources · 68

Data joins: avoid multiplying business metrics

Verify grain, keys and cardinality before totaling sales, costs or conversions.

· 2 min

Charts and statistics on a laptop screen Illustration · fictional scene

What this guide helps achieve

  • Describe the grain
  • Check cardinality
  • Reconcile totals
  • Review exclusions

Quick check

  • What does one row represent in each table?
  • Do keys have the expected cardinality?
  • Does the independent total remain unchanged?

Step-by-step method

  1. 01

    Describe the grain

    State what one row represents: order, order line, payment or event. Identify expected keys and time versions. Repeated customer keys are not necessarily faulty duplicates.

    Deliverable: grain dictionary.

  2. 02

    Check cardinality

    Count key occurrences on both sides and find null values. Compare row counts before and after joining. Define whether the expected relationship is one-to-one, one-to-many or many-to-many.

    Deliverable: key profile and exceptions.

  3. 03

    Reconcile totals

    Keep an independent sum at the business grain. Joining an order to multiple lines can repeat its amount. Aggregate at the appropriate grain before joining or define an explicit allocation, then reconcile the result.

    Deliverable: before-and-after balance.

  4. 04

    Review exclusions

    Filtering the right table after an outer join can remove unmatched rows. Measure unmatched records, time periods and time zones. Retain test cases when adding new sources.

    Deliverable: coverage report and regression cases.

Reusable worksheet

Complete with your authorised observations. These fields are a working template, not observed results.

FieldInformation to record
GrainRow meaning and expected key
CardinalityOccurrences, null values and expected relationship
ReconciliationCounts, reference sum and differences

Worked example

Illustrative situation

Fictional example: an order of 100 is linked to two product lines.

Decision and expected evidence

Summing the order amount after joining yields 200. The team aggregates lines before reconciliation and checks the independent total of 100.

Distinguish the mechanisms

MechanismPurposeCheck or limitation
INNER JOINRetain matched rowsUnmatched rows disappear
LEFT JOINRetain left-side rowsLater filters can change that effect

Management indicators

IndicatorWhat it measuresFirst action
Total differenceDifference from the independent sumBlock publication of unexplained totals
Unmatched shareKeys without a match in scopeDocument exclusions and period

Common pitfalls

  • Sum a value repeated at another grain
  • Conceal cardinality errors with DISTINCT

Frequently asked questions

Does DISTINCT fix an incorrect join?

It may conceal repeats without fixing the grain or allocation. Verify the relationship before deduplicating.

Are repeated keys always wrong?

No: order lines normally repeat an order identifier. Check against the expected grain.

What small test helps?

A fictional order of 100 with two lines should retain an order total of 100, not 200 after joining.

Official references

References consulted: . The method and worksheet propose checks to adapt to your context; they do not constitute certification.