Quick revision
The short answer
Compare the two systems at the finest grain they share, daily totals per country and then per order id, to see whether the 3 percent comes from missing, duplicated or differently valued orders. The usual causes are duplicate events from retries, cancellations and refunds that exist in CDC data but never produced events, time zone and cut-off differences, currency conversion at different times, and late events. Then make the warehouse built from transactional data authoritative for financial figures, label the event-based dashboards as operational, reconcile both pipelines daily with alerts, and define revenue once in a shared metric layer.
What to remember
In this answer, we narrowed a 3 percent revenue gap by comparing at the finest shared grain, by day, by country and finally by order id, sorting differences into missing, duplicated and differently valued orders. We listed the usual causes: duplicate events, refunds and cancellations without events, time zone and cut-off rules, currency timing and late events. Then we made the warehouse built from transactional data authoritative for financial figures, labelled event-based dashboards as operational, added daily automated reconciliation with alerts, and defined revenue once in a shared metric layer.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
Compare the two systems at the finest grain they share, daily totals per country and then per order id, to see whether the 3 percent comes from missing, duplicated or differently valued orders. The usual causes are duplicate events from retries, cancellations and refunds that exist in CDC data but never produced events, time zone and cut-off differences, currency conversion at different times, and late events. Then make the warehouse built from transactional data authoritative for financial figures, label the event-based dashboards as operational, reconcile both pipelines daily with alerts, and define revenue once in a shared metric layer.
Why this question is asked
Two dashboards with two different revenue numbers is one of the most damaging problems a data team can have, because it destroys trust in both. With a board pack due on Friday, the pressure is to pick a number quickly, but the senior answer is to find the cause systematically and then change the system so the gap cannot silently return. Interviewers ask this to see that method and judgement. In this answer, we will narrow the gap by drilling down from totals to orders, list the usual causes and how each shows up, decide which system is authoritative, add automated reconciliation, define metrics once, and answer which number goes into the board pack.
1Narrowing the Gap: From Totals to Orders
A 3 percent difference in a monthly total says nothing about its cause. We break both numbers down along dimensions both systems share, starting coarse and getting finer. First by day: if the gap is spread evenly over the month, it is systematic, such as duplicates or currency; if it sits on the first and last days, it is a cut-off or time zone problem; if it sits on one day, it is an incident. Then by country, channel and currency, and finally by order id.
At order level there are only three kinds of difference: orders present in ClickHouse but not in the warehouse, orders present in the warehouse but not in ClickHouse, and orders in both with different amounts. Counting the gap in each bucket usually points straight at the cause. Because the event side has no reliable order table, we aggregate events by order id first, then join on order id to the warehouse.
- Compare monthly totals3 percent gap
- Break down by dayspread evenly, or at month edges?
- Break down by country, currency, channelwhere is the gap concentrated?
- Join by order idonly in events, only in warehouse, different amount
- Explain each bucketduplicates, refunds, cut-off, FX, late events
5 steps in order. Play them, or step through them one at a time.
2The Usual Causes and How They Show Up
Duplicate events are the most common cause of the event side being higher. Producers retry after a timeout, consumers reprocess after a rebalance, and without deduplication by event id, an order is counted twice. They show up as orders with more than one event. Cancellations and refunds are the next: the orders database records them as status changes or refund rows that CDC delivers to the warehouse, but the product may never emit a cancellation event, so ClickHouse keeps counting revenue that no longer exists.
Time boundaries come next. ClickHouse may bucket by UTC while finance books by the company's local time, or by order time versus payment capture time, moving orders across the month boundary. Currency conversion can differ: the event pipeline converts at the moment of the event, finance at a daily or monthly booked rate. And late events, which arrive after a dashboard snapshot was taken, or a CDC backlog during the month, change totals depending on when each side was read.
| Cause | Signature at order level | Direction |
|---|---|---|
| Duplicate events from retries | same order id counted twice | events higher |
| Cancellations or refunds without events | order in events, refunded in warehouse | events higher |
| Time zone or cut-off rule | gap at month edges | either |
| Different FX rate or timing | same orders, small amount differences | either |
| Late events or snapshot timing | orders missing on one side near the end | either |
3One Authoritative Source for Financial Figures
Once the causes are known, we decide which system answers which question. Financial revenue, the number in the board pack, the accounts and the auditors' reports, comes from the warehouse built from the transactional orders database, because that data reflects what actually happened to each order, including refunds and cancellations, and uses finance's booking rules. The ClickHouse dashboards remain valuable for product decisions, near real-time trends and experiments, but they are labelled as operational: fast, approximate, not for financial reporting. That label belongs on the dashboard itself, not only in a wiki.
4Automated Daily Reconciliation
The investigation should become a job. Every day, a reconciliation compares order counts and revenue per day and country between the two pipelines, and stores the difference. An alert fires when it exceeds a threshold, say 0.5 percent, and the order-level breakdown query runs automatically to show the bucket. The event pipeline also gets deduplication by event id, and cancellation and refund events where they are missing, so the gap shrinks to the expected small differences in timing. Reconciliation turns a Friday crisis into a Tuesday ticket.
5Define Revenue Once
The deeper cause is that two teams wrote two definitions of revenue: one counts orders placed, another counts payments captured net of refunds, each with its own currency and time rules. A shared semantic layer or metric definitions, for example in dbt's semantic layer or the BI tool's metric store, defines revenue once, with its filters, time zone, currency rule and treatment of refunds, and both systems compute it from that definition, or clearly name a different metric, such as gross order value, when they cannot. Then different numbers have different names, and nobody has to explain why revenue is not revenue.
6Follow-up questions
Which number do you put in the board pack while the investigation runs?
The finance warehouse figure, because it comes from the system of record and follows the accounting rules the board expects. If the investigation is not complete by Friday, we say so in a short note: the operational dashboards show a higher figure, the difference is being reconciled, and the early findings, for example duplicate events, point to the dashboards being high. We never average the two or pick the more flattering one.
How do you make the event pipeline deduplicate?
Give each event a deterministic id at the source, and deduplicate on it in ClickHouse, for example with a ReplacingMergeTree keyed by event id and queries that use FINAL or aggregate by order id, or deduplicate in the stream processor before insert. Idempotent producers in Kafka reduce duplicates from retries but do not remove those created by application-level resends.
Should the dashboards be fed from CDC instead of events?
Feeding revenue tiles from the same CDC stream as the warehouse removes most causes of disagreement and is often the best long-term fix for financial metrics, while product behaviour metrics stay on events.
7Conclusion
In this answer, we narrowed a 3 percent revenue gap by comparing at the finest shared grain, by day, by country and finally by order id, sorting differences into missing, duplicated and differently valued orders. We listed the usual causes: duplicate events, refunds and cancellations without events, time zone and cut-off rules, currency timing and late events. Then we made the warehouse built from transactional data authoritative for financial figures, labelled event-based dashboards as operational, added daily automated reconciliation with alerts, and defined revenue once in a shared metric layer.
Open with
I would treat it as a drill-down, not a debate. First break both numbers down by day, then by country and currency, to see whether the gap is spread evenly, at the month edges or on specific days.
Then, if they want more
Then go to order level: aggregate the events by order id, join to the warehouse orders, and sort every difference into only in events, only in the warehouse, duplicate events, or different amount. That usually names the cause.
The typical ones are duplicate events from producer or consumer retries without deduplication, cancellations and refunds that CDC sees but that never produced events, UTC versus local time or different cut-off rules, currency converted at different moments, and late events after a snapshot. With a three percent gap where events are higher, I would expect duplicates and refunds first.
Then I would change the system. Financial revenue comes from the warehouse built from the transactional data, and the ClickHouse dashboards are labelled operational. A daily reconciliation compares counts and totals per day and country with an alert above a threshold. And revenue is defined once in a shared semantic layer so both sides use the same rules.
For the board pack, I would use the finance warehouse number with a short note on the open investigation.
About this answer
- Last updated
- 13 November 2026
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the official documentation for the version you use. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "How do you find where the numbers diverge, and what do you change so the two systems...": https://scrivio-interview-library.netlify.app/architecture/storage-and-pipelines/22edc2103a/