A Power BI Reconciliation Alert Exposed a Two-Year-Old ERP Bug
From the publisher’s feed, collected in the ZeroLabs newsroom.
A 6:23 AM reconciliation alert, a day of detective work, and a deprecated column that explained why 0.7% of our transactions were quietly being miscounted.The alert came in at 6:23 AM on a Wednesday.I was still in bed. My phone was face-down on the side table, but the Teams notification was loud enough to make our cat lift her head. I rolled over, picked up the phone, and read the message in the dim morning light:⚠ Tolerance breached: revenue_by_segment_premium Power BI value: ₹4,82,90,000 ERP value: ₹4,79,52,000 Drift: 0.70% (tolerance: 0.5%)It was the reconciliation framework I’d built six months earlier — the one I wrote about in the last post. Three components, fifteen canonical metrics per model, a Teams channel with three people in it. Most days the channel produces nothing. That Wednesday it produced this.A 0.7% drift on Premium-segment revenue. Three lakh thirty-eight thousand rupees of difference between what Power BI was reporting and what the ERP was telling us. Not enormous in the grand scheme. Large enough that if it kept growing, it would matter. Definitely large enough that I wanted to know where it came from before our 9 AM exec sync, when the same segment number would be on a slide.What followed was a day of detective work that I want to walk through carefully, because I think the shape of it — symptom in 24 hours, cause in a day, conversation longer than both — is the shape that most upstream data bugs take, and analysts rarely get to see how they actually unfold.The Teams Alert That Led to a Two-Year-Old BugThe First HourI made coffee. I opened my laptop. I pulled up the reconciliation_log table in Fabric and looked at what the framework actually had.The discrepancy wasn’t new. That was the first thing I noticed. The reconciliation runner had logged 0.3% drift on revenue_by_segment_premium two days earlier — under the tolerance threshold, so no alert. Then 0.5% the next day. Then 0.7% on Wednesday morning, which finally crossed the line. The drift was growing. Slowly, but in one direction.A drift that grows in one direction is almost never a refresh-timing issue. Refresh timing produces noise — random fluctuations that hover around zero. A monotonic growth pattern means something is systematically changing, transaction by transaction, in a way that affects Power BI’s count but not the ERP’s count, or the other way around.I ran the same SQL the framework runs, but at the transaction level instead of aggregated. About 12 million rows for the current quarter. I asked Power BI the same question through the XMLA endpoint — same transaction IDs. Then I diffed the two result sets.By 7:15 AM, I had a list. Roughly 8,400 transactions that the ERP was reporting one revenue figure for, and Power BI was reporting a slightly different figure for. Not absent from one side or the other — present on both, but with mismatched amounts. The mismatch was small per row, usually between 0.5% and 1.2% of the transaction’s total. Aggregated, it explained almost exactly the 0.7% segment-level drift.That narrowed the search dramatically. The bug was a value-level drift, not a row-level drift. It wasn’t that we were missing transactions. It was that the amounts on a specific subset of transactions were being calculated differently somewhere along the pipeline.The Second HourI looked at the 8,400 mismatched transactions for a pattern.The first cut: time. When were these transactions originally recorded? The answer surprised me. They were spread fairly evenly across the current quarter, but with a small clustering pattern at the start of certain weeks. Mondays and Tuesdays, mostly. That was strange enough to note but not enough to act on.The second cut: amount range. The mismatched transactions weren’t unusually large or small. The discrepancies were proportional to the transaction sizes, which suggested the bug was applying a multiplier somewhere, not adding or subtracting fixed amounts.The third cut, the one that broke the case open: currency. I asked the ERP for the original currency code on each mismatched transaction. Out of 8,400 transactions, 8,317 were tagged with a currency code I didn’t recognise. Not USD, not EUR, not INR — the three currencies we usually deal with. The code was a four-letter string that looked like an internal placeholder.I asked our ERP integration lead what the currency code was. He stared at it for ten seconds and said: “That’s the old legacy code for transactions that used to come from our acquired entity’s billing system. We deprecated it eighteen months ago. Nothing should still be tagged with that.”But things still were.The LeadThe acquired entity — let’s call it Vertex — had been folded into our main billing system about eighteen months earlier. The integration was technically complete. All new Vertex transactions came through the unified pipeline, tagged with proper standard currency codes. The legacy currency code was supposed to have been retired entirely. Old transactions tagged with it were supposed to be backfilled with the new codes during a one-time historical migration that, according to the integration documentation, had completed successfully.The fact that 8,317 transactions in the current quarter were tagged with the deprecated code meant one of three things. Either the historical migration hadn’t fully cleaned up old records and they were leaking through. Or the deprecated code was being newly generated by some path that should have been turned off. Or — most worryingly — some part of the system had been silently regressing and was now tagging current transactions with the old code.I needed to know which one. The fastest way to find out was to look at when each of the 8,317 transactions had been originally created in the source system versus when they had been last modified. If they were old records leaking through, the creation dates would be old. If they were new transactions being miscoded, the creation dates would be recent.The creation dates were all recent. Every single one of the 8,317 transactions had been created within the last two quarters. This wasn’t a migration leftover. Something in the system was currently tagging transactions with a deprecated currency code that should have been impossible to assign.By 9:47 AM, my coffee was cold, I had missed the exec sync, and I had a real lead. I sent a quick message to Sharma: “Reconciliation alert traced. The currency code thing isn’t a legacy data issue — it’s a live regression. Going to need to talk to the ERP team. Skip me on the 11 AM stand-up.”The CauseThe ERP integration team picked up my Slack at 10:15 AM. Their lead — let’s call her Meera — pulled the message into a ticket, opened the relevant code in the integration repository, and walked me through what she was looking at on a screen-share.The legacy currency code was being applied by a single function in a module called vertex_legacy_handler.py. The module, according to her, was supposed to have been removed when the historical migration finished. It hadn't been. Someone had left it in the codebase — disabled, but not deleted — with a comment that read "Kept for reference, do not enable."The deletion had been on a backlog ticket that had been deprioritised twice and eventually forgotten.That much, she said, was annoying but not a bug. The module wasn’t supposed to be active. The bug was that, two years ago, before the migration, someone had wired the function into a callback that fired whenever a specific kind of edge-case transaction came in — refunds against orders that had originally been processed through Vertex’s billing system. That callback registration had also never been removed. So whenever one of these specific refund transactions came in, the deprecated function was still being called, and it was still tagging the transaction with the legacy currency code.The reason this hadn’t shown up earlier was that the volume of these specific edge-case refunds had been very low — maybe ten or twenty a month — for most of the eighteen months since the migration. Then, about three months ago, a marketing campaign had targeted exactly the customer cohort that originally came from Vertex. That cohort had higher-than-average refund rates. The refund volume spiked. The deprecated function started firing more often. The drift started growing.The bug had been latent in the system for two years. It had only become visible when something completely unrelated — a marketing campaign decision made by a team that didn’t know the integration history — exercised the dormant code path enough times for the discrepancy to cross our reconciliation tolerance.How the Bug Stayed Hidden for Two YearsThe FixThe fix itself took Meera about an hour. She removed the callback registration that wired the deprecated function into the refund pipeline. Then she deleted the vertex_legacy_handler.py module entirely. Then she opened a backfill ticket to correct the currency codes on the 8,317 transactions that had already been tagged incorrectly, which her team's batch process would run that night.The drift went away the next morning. Wednesday’s drift was 0.7%. Thursday morning’s reconciliation showed 0.02% — well within tolerance, almost certainly noise.What didn’t take an hour was the conversation about how this had stayed hidden for two years. I had this conversation with Meera over coffee the following Monday. It was the most useful part of the whole episode.She walked through the chain of decisions that had let the bug survive. The original deprecation had been done correctly — the module was disabled, the documentation was updated, the migration was completed. But the deletion of the now-orphaned code had been done as a separate cleanup ticket, prioritised below “important” work. That ticket had been bumped from sprint to sprint. The team that owned the integration had reorganised twice in the intervening period. The callback that should have been removed alongside the function had been registered in a different module that nobody mapped back to the deprecated handler when reviewing what to delete. The historical context of why the callback existed wasn’t in any documentation she could find — it was knowledge that had walked out the door with the person who’d originally written it.None of these were dramatic failures. Each one was a small, defensible decision made by a competent team under pressure. The bug was the compound effect of those small decisions, multiplied by time, exposed by an unrelated marketing campaign that nobody could have predicted.This is what I want analysts who build reconciliation frameworks to understand: the bugs you’ll catch are rarely caused by anyone doing anything obviously wrong. They’re caused by the way modern data systems accumulate decisions, change owners, and forget their own history. Reconciliation isn’t about catching incompetence. It’s about catching the slow drift of competently-built systems over time.What I Take From ThisA few things stayed with me from that Wednesday.The framework caught the symptom in 24 hours of the drift becoming statistically significant. Without it, we would not have known. The 0.7% drift would have continued growing, the marketing campaign would have continued exercising the dormant code, and by the time someone in finance noticed segment-level revenue felt off — probably two quarters in, just like last time — the discrepancy would have been measured in lakhs, not thousands. The framework worked exactly as intended. Catching upstream bugs is the use case it was actually built for, even though I didn’t know that when I built it.Tracing the symptom to the cause took a day of focused detective work. I want to be honest about this part: a less curious analyst, or one with a more demanding calendar that morning, might have logged the alert, looked at the drift, decided it was small enough to ignore, and moved on. That would have been a defensible choice in the moment. It would also have left the bug in place, growing, until it crossed some other threshold and forced a more expensive investigation later. Investigating small drifts when they first appear is one of the highest-leverage uses of an analyst’s time. The trade is two or three hours now against two or three weeks later. I’m not sure I would have understood that trade if I hadn’t lived through this one.The conversation with the ERP team took longer than the fix. Meera and I spent about ninety minutes on the coffee meeting. Some of that was understanding what had failed. Most of it was agreeing on how we’d reduce the chance of the same shape of failure happening again — better cleanup ticket tracking, a convention for documenting why callbacks exist, a quarterly walk-through of disabled-but-undeleted code. None of those changes are dramatic. All of them will take real effort to maintain. They’ll only pay off when they prevent the next bug, which by definition we won’t notice.The most lasting thing I took from this was a different relationship with the reconciliation framework itself. Before this incident, I thought of it as protective infrastructure — a safety net under my work. After this incident, I think of it as something more like a microscope. It’s the instrument that makes invisible drift visible. The drift already existed. The framework just made it visible before it became expensive.A Power BI Reconciliation Alert Exposed a Two-Year-Old ERP Bug was originally published in Towards AI on Medium, where people are continuing the conversation by highlighting and responding to this story.