Lab NotebookEntry 03AI that decides

First the quantities, then the AI

What changes when the AI receives the numbers already computed, with a definition and a period, instead of the raw rows of the table. A sum to do with your own hands before asking a machine.

The same table of 13 orders answers "how much did we sell in October?" with €4,200, €3,600, €2,800 or €2,900. Against September, the month went up 71.43% or down 3.45%. None of the sums is wrong. What is missing isn't arithmetic: it's the definition nobody wrote down.

Don't ask the AI to count the boxes in the stockroom. Hand it the stock already counted and ask what to do with it.

Origin
A request that keeps coming up in AI projects: hand over the whole table and ask for the analysis. No client identified.
Data
13 made-up orders, September to November 2026, always the same. No data from any real project.
Two voices
In the notebook, for the people who build the model. On a napkin, for the people who hold the budget
Benches
1 · Do the sum yourself (the raw table, your answer and the four definitions)

One question, four answers

A small shop: 13 orders over three months, three products. Each row of the table has the order date, the delivery date, the store, the product, the price, the quantity and how many units came back. Management asks what management always asks: how much did we sell in October?

There are four ways to answer, all defensible:

Between the largest and the smallest there is €1,400. And the next question makes it worse: was October better than September? By gross sales on the delivery date, it went up 71.43%. By net sales on the order date, it went down 3.45%. The same table and the same month give a rise of more than seventy percent or a fall.

None of these sums is wrong. Two orders show where the difference comes from. One was placed on 29 September and delivered on 2 October: €900 that belong to September under one definition and to October under the other. The other, placed on 30 October, only arrived on 3 November, and half of it came back: eight blenders sold, four returned.

Now replace management with an AI. You hand over the whole table and type "how much did we sell in October?". It will give you a number, in a well-built sentence. Which of the four?

Where this came from

The request comes up often in AI projects, almost in the same words: process the whole table and generate the analysis. The home version is dropping the CSV into the chat and asking for "insights". The answer comes back fast, confident and well written. The number in it has no origin, and the metric has no definition.

This entry is the question that request leaves behind: what changes when the AI receives the quantities already computed, with a definition and a period, instead of the raw rows?

In Entry 02 the sum was about when to let the AI answer on its own. This one is a step earlier: what to put in front of it.

Calculating is one thing, interpreting is another

Answering "how much did we sell in October?" takes two decisions and one sum. The decisions: what counts as a sale (what went out, or what went out and didn't come back) and on which date the sale counts (when the customer ordered, or when they received it). The sum comes afterwards, and it's the easy part:

Vgross = Σ p·q   ·   Vnet = Σ p·(q − d)
(1)

where p is the price, q the quantity and d the quantity returned, adding up only the rows whose chosen date falls in the month.

The calculation is deterministic. Written in SQL or in pandas, it gives the same result every time, and it can be tested with a small table whose answer is known. Interpretation is a different activity: looking at −3.45% next to +40.00% and asking what happened to the returns.

When the raw table goes to the AI with a request for analysis, the two activities get mixed, and three things happen silently:

A physicist's detour

Quantity is a physics word

Nobody hands a physicist the list of a car's positions and asks for the average velocity without saying between which instants and in which unit. And even then a choice remains. A car drives to the next town and comes back. If the quantity is displacement divided by time, the average velocity of the trip is zero. If it is distance travelled divided by time, it isn't. Both sums are right; they measure different things. Gross sales are the distance travelled. Net sales are the displacement: what went and came back doesn't count. First you define the quantity, then you calculate, and only then do you interpret. Dimensional analysis is the habit of not skipping that order.

A sales table doesn't hold "October's sales". It holds several, and someone has to choose which one before asking.

Do the sum yourself

The bench below shows the raw table, with the 13 orders, and asks the opening question: how much did we sell in October? Answer before reading on. A calculator is fine, a spreadsheet is fine, adding in your head is fine.

Bench · Do the sum yourself

13 made-up orders · September to November 2026

How much did we sell in October? Do the sum with the table below before opening the answers. Values are in euros.

orderorder datedelivery datestoreproductpricequantityreturned
P012026-09-032026-09-05Centralcoffee maker20020
P022026-09-102026-09-12Northblender15040
P032026-09-182026-09-21Centraltoaster10051
P042026-09-242026-09-26Northcoffee maker20030
P052026-09-292026-10-02Centralblender15060
P062026-10-022026-10-05Northtoaster10040
P072026-10-082026-10-10Centralcoffee maker20052
P082026-10-142026-10-16Northblender15020
P092026-10-202026-10-23Centraltoaster10063
P102026-10-272026-10-29Northcoffee maker20020
P112026-10-302026-11-03Centralblender15084
P122026-10-312026-11-02Northtoaster10031
P132026-11-042026-11-06Centralcoffee maker20010
Check: the four answers
definitionOctober
Gross sales, by order date€4,200
Gross sales, by delivery date€3,600
Sales net of returns, by order date€2,800
Sales net of returns, by delivery date€2,900

Look for your answer in the list. If it is there, that is the definition you used without anyone asking. If it isn't, go back over the sum: two definitions probably got mixed. Between the largest and the smallest answer there is €1,400.

The second part: the table of quantities
quantityOctoberSeptemberchange
Gross sales, by order date€4,200€3,000+40.00%
Gross sales, by delivery date€3,600€2,100+71.43%
Sales net of returns, by order date€2,800€2,900−3.45%
Sales net of returns, by delivery date€2,900€2,000+45.00%

Gross sales: price × quantity. Net sales: price × (quantity − returned). By order date: it counts in the month the order was placed. By delivery date: it counts in the month it arrived. The return is deducted in the month of the sale itself.

After you check, the bench shows the four definitions and tells you which one your answer matches. If it matched one, notice that you picked a definition without anyone asking, probably the one you use at work. If it matched none, you probably mixed two: counted one order by delivery date and another by order date, or deducted one return and forgot another. It is the mistake the raw table invites, whoever receives it.

The second part of the bench swaps the raw table for the table of quantities:

That is four rows instead of thirteen, and every number has a name. With this table in front of you, "how much did we sell in October?" stops being a question with a hidden answer: it depends on which row you want, and each row says what it is. And the question worth asking an AI, or an analyst, appears: why did gross sales rise 40.00% and net sales fall 3.45% in the same month? The answer is in the returns. October's orders had €1,400 returned, against €100 for September's.

The table the AI should receive

The table of quantities is not just the table summarised. It is a summary with three things written next to each number:

With that, the request to the AI changes in nature. Instead of "analyse this table", it becomes "here are the four measures of October sales, with the definition of each and the comparison with September; explain the difference between them and say what deserves attention". The arithmetic arrives done and checked. What is left for the AI is to compare, explain and write.

There is one more practical advantage: you can check the answer without a magnifying glass. Every number that appears in the AI's text has to be one of the numbers in the table of quantities, or a simple operation between two of them. A number that isn't there was made up, and a short program finds it.

What matters to whoever pays

Where the money is

How to use this in practice

1. Write the definition before the query

For each metric the AI will use: what goes in, what stays out, on which date it counts and which period it is compared with. One sentence per metric is enough. If two departments use different definitions, both go in, each under its own name.

2. Calculate in code you can test

SQL, pandas, whatever the team already uses. And a test with a small table whose answer is known, like the one in this entry: 13 rows, four answers, all checked by hand. When someone touches the definition, the test tells you.

3. Hand over the table of quantities, with the glossary

The AI receives the computed measures, the definition of each one and the period. The raw rows stay in the database.

4. Ask for interpretation, not arithmetic

"Explain the difference", "what deserves attention", "write the summary for management". If the analysis calls for a new cut, by store or by product, the cut goes back to step 2: it becomes a new quantity, computed in code.

5. Check the numbers in the answer

Every number in the final text has to exist in the table of quantities. That check is automatic and cheap. After it, someone with a name signs the report before it goes up.

Mandatory section

Where this breaks

To reproduce

The core of the sum fits in a few lines, with nothing but Python's standard library:

def vendas(linhas, mes, valor, data):
    """Month total under the chosen definition.
    valor: "bruto" (gross) or "liquido" (net); data: "pedido" (order) or "entrega" (delivery)."""
    total = 0
    for linha in linhas:
        if linha["data_" + data][:7] != mes:
            continue
        quantidade = linha["quantidade"]
        if valor == "liquido":
            quantidade -= linha["devolvida"]
        total += linha["preco"] * quantidade
    return total

vendas(linhas, "2026-10", "bruto", "pedido")      # 4200
vendas(linhas, "2026-10", "bruto", "entrega")     # 3600
vendas(linhas, "2026-10", "liquido", "pedido")    # 2800
vendas(linhas, "2026-10", "liquido", "entrega")   # 2900

References

Long contexts

  1. Liu, N. F., Lin, K., Hewitt, J., Paranjape, A., Bevilacqua, M., Petroni, F. & Liang, P. (2023). Lost in the Middle: How Language Models Use Long Contexts. arXiv:2307.03172, accepted at Transactions of the Association for Computational Linguistics.performance drops when the relevant information sits in the middle of a long context

The model writes, the program calculates

  1. Cheng, Z., Xie, T., Shi, P. et al. (2022). Binding Language Models in Symbolic Languages. arXiv:2210.02875.the model turns the question into a program; an executor does the sum
  2. Wang, Z., Zhang, H., Li, C.-L. et al. (2024). Chain-of-Table: Evolving Tables in the Reasoning Chain for Table Understanding. arXiv:2401.04398.the reasoning goes through intermediate tables, one operation at a time

Want to know whether your tables are ready for AI?

Vettore Data runs the diagnostic: it lists the metrics the AI will use, writes down the definition of each one with the people who know the business, and says what to calculate first. The executive version of this entry, with a three-question test, is there.

See the diagnostic at Vettoreor get in touch