Writing

When two numbers disagree, price every difference

Two definitions of the same metric can be split into their real differences, each priced so the amounts sum exactly to the gap and classed as a policy choice or a data defect

Summary

Every organization that reports a metric from more than one place eventually faces the meeting where two numbers for "revenue", "spend" or "headcount" disagree and nobody can say why. The usual response is days of side-by-side spreadsheet work that ends in a plausible story, not a reconciliation.

This paper describes a different approach. Take the two definitions exactly as written, in SQL or as a Power BI DAX measure; break each into its clauses; run every combination of the two sets of clauses against the data; and use Shapley values from cooperative game theory to attribute the gap to each difference. The method is implemented in a browser-based tool, a prototype built in September 2026 and tested on sample data with 51 automated tests. It has not yet been used on a client engagement.

  • There is no residual line. Shapley values are built so that the attributions add up to the gap exactly, to the cent.
  • Definitions are compared, not just outputs. Each definition is parsed into clauses and cosmetic differences are normalized away, leaving only the real differences.
  • The data is examined as well as the logic. Duplicate keys, joins that multiply rows, blanks and renamed categories are each linked to the differences they drive.
  • Every difference has a type. Each is classed as a policy choice someone must own or a data defect someone must fix.

1. Why two numbers disagree

Two numbers for the same metric rarely disagree for one reason. In a typical case, the Finance revenue figure in the board pack and the Sales revenue figure in the CRM dashboard differ because of several decisions at once.

Difference Finance Sales
Which date counts Invoice date (recognized revenue) Order date (bookings)
Which records count Excludes refunded orders and internal test accounts Excludes only cancellations
Which amount counts Nets off discounts List price

A fourth difference sits in the joins. One definition joins to a customer table that holds duplicate IDs after a CRM merge, silently counting some orders twice.

Each of these is easy to spot once you know to look. The hard part is the question leaders actually ask: how much of the gap does each one explain? Differences interact. Excluding internal accounts removes a different amount depending on whether refunds have already been removed, and a duplicated join inflates whatever else is in the query.

So removing differences one at a time gives a different answer for every order tried, and the pieces never add up to the gap. Analysts end up presenting a reconciliation with a "residual" or "timing and other" line that absorbs whatever they could not explain. That part of the gap stays unexplained.

There is a second cost. Some differences are legitimate policy choices (Sales is meant to count bookings), while others are defects (nobody intended the duplicate join). Mixing the two in one narrative means defects get defended as policy and policy disagreements get treated as bugs.

Mixing the two in one narrative means defects get defended as policy and policy disagreements get treated as bugs.

2. Price each difference, not the whole gap

The input is the two definitions as they are actually written: the SQL behind a report or the DAX measure behind a Power BI visual. Each is parsed into clauses: the measure expression, each join, each filter condition, distinct and grouping. Cosmetic differences such as aliases, case, spacing and the order in which joins are written are normalized away. What remains is the list of real differences.

Each difference is then priced with Shapley values, the same principle used to split costs fairly among partners. With n differences, every one of the 2ⁿ hybrid queries that take some clauses from definition A and the rest from definition B is built and run. Each difference's share of the gap is its average marginal effect across all the orders in which it could be switched on.

This has one property that matters for a reconciliation, and it holds by design rather than by testing: the shares always sum exactly to the gap. There is no residual line.

The data X-ray

Before comparing, the data itself is profiled for:

  • blank values in numeric and date columns;
  • keys that are not unique;
  • joins that multiply rows;
  • orphaned references;
  • category values that look renamed (one value stops on a date and a new one starts the next).

Each finding is linked to the differences it affects, so a result reads "this join is worth X of the gap, because this table has duplicate customer IDs."

Policy choice or data defect

Each difference is classed as one of two types. Policy items carry a suggested owner, so the follow-up is a decision rather than another investigation.

Type What it is Example Follow-up
Policy choice A deliberate definitional decision Invoice date versus order date A suggested owner decides, such as the controller (revenue policy) or the CFO (recognition timing)
Data defect An unintended effect A fan-out join, or a filter that cannot reach the table it is meant to filter Someone fixes it

Power BI measures as first-class inputs

Many disagreements are between a SQL report and a Power BI measure. The tool translates a DAX measure into equivalent SQL, inferring relationships from the data and following Power BI's own rules: filters flow from the one side to the many side, filters never multiply rows, and blanks behave as DAX treats them (added as zero, skipped by SUM). The translated SQL is shown beside the original, and each difference shows the DAX expression it came from.

3. How a comparison runs

From the user's point of view, a comparison can be run in a working session:

  1. Load the data as CSV files, one per table.
  2. Paste definition A and definition B, each in SQL or DAX, with a label and source (for example "Board pack, Q1" and "CRM dashboard, Q1").
  3. Read the result: the two totals, the gap, and one card per difference showing its dollar contribution, its type (policy or defect), the data findings behind it and the suggested owner.

A plain-language narrative summarizes the reconciliation for a non-technical reader. Behind those three steps, the tool works in this order:

  1. The data X-ray profiles the CSV files for blanks, duplicate keys, fan-out joins and renamed categories.
  2. Both definitions are parsed and normalized into clauses.
  3. Every hybrid query (2ⁿ of them for n differences) is run against the data.
  4. Shapley attribution assigns each difference its share of the gap.
  5. The attributions and the data findings are combined into the difference cards and the narrative.

The tool is a single web page. All computation runs in the browser on an embedded SQLite engine compiled to WebAssembly, so client data never leaves the analyst's machine and nothing needs to be installed or hosted. The comparison engine has no user-interface dependencies and also runs under Node.js, which allows the same checks to be scripted. Up to twelve independent differences are supported, which means at most 4,096 queries per comparison.

4. Status and limits

The tool is a prototype built in September 2026. It has been tested on sample data with 51 automated tests and has not yet been used on a client engagement, so what follows describes what it does, not client outcomes.

The test case is a seeded sample company with three tables (customers, orders, order lines) and five planted problems: internal test accounts, customer IDs duplicated by a CRM merge, a product line renamed partway through the period, blank discounts, and refunded and late-invoiced orders. The sample reconciles a Finance SQL definition against a Sales SQL definition, and the same Finance definition against a Power BI measure. In both cases the attributions sum exactly to the gap, as Shapley values guarantee by design.

The 51 automated tests cover the end-to-end sample, SQL parsing edge cases, CSV handling and the DAX translation. The end-to-end test runs the full sample case through parsing, attribution and the data findings. The DAX translation is checked against an independent evaluation of the same DAX rules, not against itself.

Version 1 has stated limits:

Input Supported Not yet supported
SQL A single-value SELECT (with an optional WITH block), all join types, AND-combined filters, DISTINCT, GROUP BY/HAVING Comma joins
DAX CALCULATE at the top of a measure, FILTER, the common aggregations and iterators, DATESBETWEEN, RELATED and DIVIDE, among others References to other measures, USERELATIONSHIP, most time-intelligence functions

Each unsupported construct produces a clear error rather than a wrong answer.

5. Where this applies

The method fits any metric that is defined in more than one place:

  • Revenue and bookings between finance close, CRM and board dashboards.
  • Procurement spend between AP extracts, spend-analytics platforms and category reports, where vendor de-duplication and date basis can move totals.
  • Headcount and FTE between HR, payroll and finance.
  • Migrations, when a legacy report is rebuilt in Power BI and the new number does not match the old one.
  • Audit and data governance, where a documented, additive reconciliation is worth more than a narrative.

6. Lessons for the next reconciliation

  1. Additivity removes the residual line. Sequential "remove one difference at a time" reconciliations change depending on the order chosen. A breakdown that always sums to the gap removes the residual line, and every amount in it belongs to a named difference.
  2. A gap can be part policy, part defect. Separating the two turns "whose number is right" into two narrower questions: which choices to keep, and which errors to fix.
  3. Look at the data, not only the formulas. A definition can be perfectly reasonable and still wrong on this data because of a duplicate key or a renamed category. The data X-ray is what turns a difference into an explanation.
  4. Refuse rather than guess. Where a construct is not supported, the tool says so explicitly. For a reconciliation tool, a clear "not yet" is far better than a confident wrong number.