← Back to SQL, page 22

sql-0435 · Medium mid

Two dashboards show different revenue for the same month. How would you find out why?

Compare the definitions line by line: which statuses count (cancelled, refunded), which date defines the month (order date, ship date, payment date), the time zone, currency conversion, tax and discounts, and joins that may duplicate or drop rows. Reconcile at a fine grain, such as per day or per order, to find where the numbers diverge, then agree on one documented definition.

Full answer

Typical causes:

  • Filters: one includes cancelled or test orders, the other excludes them.
  • Dates: one uses order_date, the other paid_at; month boundaries in UTC versus local time.
  • Joins: a join to order items and payments together fans out rows and inflates sums; an inner join to a lookup drops rows without a match.
  • Amounts: gross versus net of discounts, tax, shipping or refunds; mixed currencies.
  • Freshness: one reads a replica or a nightly snapshot.

Method:

  1. Get both SQL statements.
  2. Run both at the order level and full-outer-join the results on order id to see which orders differ.
  3. Explain each difference category and its amount.
  4. Agree on a definition, put it in a shared view or semantic layer, and point both dashboards at it.

Metric definitions belong in one place; otherwise every new report invents its own.

Key points

  • Compare definitions, not just numbers
  • Reconcile at order level
  • Check fan-out and dropped rows
  • Time zones and date choice matter
  • Centralise metric definitions

Common mistakes

  • Adjusting one dashboard to match without understanding why
  • Comparing only monthly totals

Follow-ups

  • How would a full outer join help reconcile?
  • How would you test a metric definition?

Tips

  • Reconcile at the finest grain