← All insights

The total row

The row that is not a state Andhra Pradesh 4,812 Bihar 11,003 Chhattisgarh 3,940 West Bengal 13,275 Total (All India)530,333 a row, not a footer sum(column) 1,060,666 the real figure 530,333 exactly twice, which is why nothing looks wrong

Here is an error we have now made, caught, and written a check against enough times to be confident it is not a personal failing.

A published statistical table has one row per state. It also has a row called Total, or Total (All India), or simply All India, sitting in the same column with the same formatting. A script reads the table, sums the column, and reports the national figure. The figure is exactly twice the truth.

The reason this particular error is worth a note, rather than being filed under carelessness, is that it defeats almost every check a careful person would think to apply.

It is not a plausibility failure. The number is in the right units, the right order of magnitude for a large country, and positive. If the real figure is 530,333 prisoners, 1,060,666 is not an obviously absurd number of prisoners.

It is not an internal consistency failure. The parts still sum to the same total they always did, because the total is one of the parts. A check that asks whether the column adds up passes. A check that asks whether each row's percentage matches its count passes. A check that compares this year against last year passes, because last year was computed the same way and is wrong by the same factor.

It is not a shape failure. The row count is one higher than the number of states, which looks like a union territory you had forgotten about.

And the ratios are all correct. Every state's share of the doubled total is exactly half its true share, which is wrong in a way that is uniform, so nothing stands out. A bar chart of shares looks identical in shape. Only the axis is wrong, and the axis is the thing nobody checks.

Three shapes of this that we have hit in the last year, with their multipliers.

One total, doubling. The Ministry of Corporate Affairs CSR tables carry a Total row. Summing the state column for 2022-23 returns ₹59,976 crore against a real ₹29,988 crore.

Three totals, tripling. The National Crime Records Bureau tables carry Total (States), Total (UTs) and Total (All India). Summing the column returns three times the real figure. That is the shape most likely to survive review, because a figure three times too large no longer looks like a doubling and so does not trigger the suspicion a doubling eventually does.

All India as a row among states. The MoSPI open-data API returns All India as an ordinary record in the response array, with a state field like every other record. Iterate the array and you have a thirty-seventh state whose value is the national figure. This one is the most dangerous of the three, because the response is JSON rather than a spreadsheet, and JSON feels like it has already been cleaned.

The remedy is short and it is not "be careful".

Read the total from the total row. It is published, it is authoritative, and it is what the source intends you to use.

Sum the parts separately, as a second and independent quantity.

Assert that the two agree, and refuse to write output when they do not.

That third line is the one that matters, and it is the one people leave out. A check that reports a discrepancy into a log is a check that will be ignored under deadline. A check that stops the build cannot be. We have had both versions in the same codebase and only the second one has ever caught anything, because the first one caught things at a moment when nobody was reading.

Two refinements worth adding once the basic form is in place.

Some tables have parts that legitimately do not sum to the total. Spending attributed to "PAN India", or to no state at all, is a real category in the CSR data and accounts for roughly a fifth of the money. The answer is not to drop those rows, which inflates every state's share, and not to fold them into a state, which is a fabrication. Keep them as a separate block, and let the assertion be that the states plus the unattributed block equal the published total. The check then documents the unattributed share rather than hiding it.

And a source can be internally consistent and still wrong, which no amount of total-row discipline will catch. We found a census table whose Scheduled Tribe columns were displaced across rows: Kerala's row carried another state's count and that state's percentage, so the count matched the percentage within the row, and the column still summed to the correct national total. Every internal check passed. It put Kerala at 46 per cent Scheduled Tribe against a published 1.5 per cent. The only thing that caught it was comparing a handful of states against the figures published elsewhere.

Which is the general lesson, and the one worth keeping. A number derived from a table cannot be validated against that table alone. The total row is the cheapest external reference you will ever have, because the source computed it for you. Use it, and make disagreement fatal.