Lesson 3 of 4 · 15 min

Math, data and spreadsheets

How to test numbers produced with AI.

Slide 1 of 7

The total that looked right

  • Edson works out the commission on 148 sales with AI
  • He gets a clean table and a plausible total
  • The table came back with nine rows missing

Edson handles variable pay at an equipment company. At month end, he pastes one hundred and forty eight sales into the AI and asks for the commission on each one and the total. Back comes a clean table and a figure: fourteen thousand, one hundred and two reais and sixty cents. It is close to the previous month. He almost posts it to payroll. First, he does something that takes ten seconds: he counts the rows. There are one hundred and thirty nine. Nine sales vanished along the way, and the people who made them would be paid less.

Full transcript

The total that looked right

Edson handles variable pay at an equipment company. At month end, he pastes one hundred and forty eight sales into the AI and asks for the commission on each one and the total. Back comes a clean table and a figure: fourteen thousand, one hundred and two reais and sixty cents. It is close to the previous month. He almost posts it to payroll. First, he does something that takes ten seconds: he counts the rows. There are one hundred and thirty nine. Nine sales vanished along the way, and the people who made them would be paid less.

Why the math fails

With no calculator behind it, the model produces a number the same way it produces a sentence: by the likely continuation. In simple math, it is often right. In long math, it fails, and there is research from two thousand and twenty six showing accuracy plunge in multiplications with many digits, even when the model reads the numbers correctly. Long lists bring another problem. The more text the model has to consider, the harder it is to recall each item. Hence the skipped row, the repeated amount, the total that does not match.

Test one: order of magnitude

The first test is done in your head and comes before looking at the answer. What would be the smallest and the largest possible result? Edson knows the commission is three or five percent, on about four hundred thousand in sales. So the total lies between twelve and twenty thousand. If the AI answers two thousand or one hundred and forty thousand, there is a decimal or unit error. Notice: the fourteen thousand passed this test. Order of magnitude catches the huge error. For the quiet error, you need the next tests.

Test two: control totals

A control total is a number you know beforehand and demand afterwards. In the original spreadsheet, note how many rows there are and the sum of the main column. When the result comes back, count the rows and add up the same column. No match? Nothing else matters until you find the difference. If the data has groups, such as store or salesperson, do it by group: that shows where the difference is. It is the cheapest technique in this lesson, and it is the one that caught Edson's nine sales.

Test three: ask for the formula, not the number

Instead of asking for the number, ask for the formula and apply it in your spreadsheet. The one computing is now the spreadsheet, which does not skip rows. If your tool runs code, ask it to do the math that way and to show the code. Research shows that letting the model build the program and the computer do the calculation gives better results than asking for the math directly. And there is an extra benefit: the formula is in plain sight. You can read the rule, show it to a colleague and fix it. A loose number can only be accepted or refused.

Test four: redo a sample

A right formula on crooked data is also wrong. So redo a sample of eight rows by hand: the first, the last, the largest, the smallest and four drawn at random. Include the odd cases, such as a return, an empty field and a category spelled another way. Look at the format: swapped commas and points turn one thousand two hundred and fifty into one point two five. Dates can flip day and month. And ask whether it is percent or percentage points. Going from ten to twelve percent is a rise of twenty percent, or of two points.

What to do now

Range, control totals, formula and sample. Take a calculation you already did with AI, ideally one that repeats every month, and put it through the four tests. Time yourself. It usually takes a while the first time and much less the next ones, because the control spreadsheet is ready. And if the tool changes the total on every attempt, do not average and do not pick the prettiest. Go back to the formula.

A worked case: Edson's commission

The rule: 3% on equipment and 5% on service. The data: 148 sales. Before any request, Edson wrote down the controls: 148 rows and R$ 412,650.00 in sales. Expected range: from 3% (R$ 12,379.50) to 5% (R$ 20,632.50).

The first request:

Calculate the commission on each sale below and the total. Equipment is 3%, service is 5%.

The answer: a table and a total of R$ 14,102.60. Within the range. In the controls, however, there were 139 rows and R$ 389,420.00 in sales. Nine sales were missing, worth R$ 23,230.00.

The second request:

Do not calculate. Write the formula for row 2, with the type in column C and the amount in column D. Equipment is 3%, service is 5%. Say which values in column C would make the formula go wrong.

The answer brought =IF(C2="service",D2*5%,D2*3%) and a warning: anything other than "service" would fall into 3%. Edson applied it to the 148 rows and got R$ 14,899.50, with both controls matching.

The sample was still missing. Among the eight rows redone, one was typed "serv.". He filtered the column and found three, adding up to R$ 4,000.00, paid at 3% instead of 5%. He fixed the spelling. Final total: R$ 14,979.50.

TestWhat it showed
RangeNothing: the wrong total fit in it
Control totalsNine lost rows
FormulaThe rule, and where it breaks
SampleThree rows with different spelling: R$ 80.00

Each test caught an error the others would miss. And notice that the last error was not the AI's: it was in the data. Research on spreadsheets, long before generative AI, had already concluded that errors are common and significant.

And when the tool really computes?

Some tools run code or use a calculator. In that case the math is usually right, and the error moves elsewhere: a misunderstood rule, a swapped column, an oddly formatted row ignored. Ask how it was calculated, and ask for the code and the list of discarded rows. The control totals still apply.

Before the exercise

  1. Note rows and sum first. Demand them afterwards.
  2. A formula in plain sight is worth more than a finished number.
  3. The quiet error lives in the exceptions.

Exercise

The four tests on a calculation of yours

Redo a calculation from your work with a formula and put the result through the four tests.

Step by step

  1. Choose a table with 30 rows or more. Replace names and identifiers with codes and remove columns that are not part of the math.
  2. Before using AI, write down the expected range, the number of rows and the sum of the main column.
  3. Ask for the formula with the starter text, apply it in the spreadsheet and compare it with the control totals.
  4. Redo eight rows by hand, including the exceptions, and record what you found.

Starter text

I want to calculate [what] in a spreadsheet. Do not compute the values: write the formula.

Spreadsheet columns:
A: [column name and an example value]
B: [column name and an example value]
C: [column name and an example value]

Calculation rule, in words: [the rule, with the exceptions you know]

Deliver:
1. The formula for row 2, ready to copy down.
2. What the formula does, one sentence per part.
3. The values that would make the formula go wrong (blank, text, negative, different spelling).
4. Two control formulas: one that counts rows and one that sums.

How to tell if it's good

Wrote down the controls first
Shows the expected range, number of rows and sum recorded before seeing the result.
Replaced the number with the formula
Shows the formula or code used and explains the rule in their own words.
Redid a sample that includes exceptions
Lists the eight rows, with at least two unusual ones, and the result of each.
Concluded with evidence
Says whether the total can be used and points out the difference found or the matching controls.

Do not use personal data or confidential information in the exercise.

Check

Four situations. Three right answers complete the lesson, and you can try again.

  1. Situation 1

    Situation 1

    You pasted 300 expenses into the AI and it returned the total by category. The amount is similar to last month's. Which test comes first?

  2. Situation 2

    Situation 2

    You need to raise 2,000 prices by 4.87%, rounding them to end in ninety cents. How do you use AI?

  3. Situation 3

    Situation 3

    You asked the same question twice and the quarter's revenue came back with two different totals. What do you do?

  4. Situation 4

    Situation 4

    The formula the AI suggested worked on row 2 and you copied it to all 900 rows. The total came out a little below what you expected. Which likely cause do you investigate?

Take away

Checking the math in four tests

Checklist

BEFORE asking
[ ] Expected range: between [smallest] and [largest], because [mental math]
[ ] Rows in the data: [count]
[ ] Sum of the main column: [amount]
[ ] Sum by group (store, person, month): [amounts]

WHEN asking
[ ] I asked for the formula or the code, and not the number
[ ] I described the rule in words, with the exceptions
[ ] I asked for the cases where the formula would go wrong

AFTERWARDS
[ ] The result is within the range
[ ] Rows and sums match what I noted, overall and by group
[ ] I redid by hand: first, last, largest, smallest and four drawn at random
[ ] I tested the exceptions: blank, negative, return, different spelling
[ ] I checked format: decimal marks, day and month, percent and percentage point, unit and currency
[ ] I kept the spreadsheet with the formula, the date and the name of who checked

If the math changed between two attempts, neither one is usable.