How to get exact answers from a spreadsheet with an AI model
Ask a chatbot to total a column and it will give you a number, confidently, and that number is often wrong. This is a guide to why that happens and what to do about it. It applies to any tool — the fix is a technique, not a product.
Why the number comes back wrong
Three separate failures, usually stacked:
- The model never saw the whole file. Long tables are truncated or sampled to fit the context window. A model asked to sum 4,000 rows may have been shown 200.
- The arithmetic is done by a language model. Predicting the next token is not addition. It's approximately right, which is the worst kind of wrong for a number you're going to act on.
- Retrieval splits the table. Tools that chunk documents for search cut a spreadsheet into fragments, and a fragment of a table is close to meaningless — the header row ends up separated from the numbers it labels.
None of these announce themselves. You get a plausible figure with no warning that it was estimated from a sample.
The three approaches that work
1. Make the model write a query, and run the query elsewhere
This is the one to reach for. The model is good at turning "what did we close in December"
into SELECT SUM(revenue) FROM data WHERE month = '2025-12', and bad at being the
thing that executes it. Let it do the translation, and let a database or a Python process do
the maths.
Practical test for any tool: can you see the query it ran? If yes, the number was computed. If there's no query to show, it was estimated.
2. Pre-aggregate before you ask
If your tool can only read text, do the reduction yourself first. A pivot table that turns 40,000 rows into 12 monthly totals will fit in any context window, and the model can then reason about something small and complete rather than guess about something large and partial. Less elegant, entirely reliable.
3. Narrow the file, then ask
Filter to the rows and columns the question actually needs and export just those. "Sales, 2025, North region" is a small file. Most spreadsheet questions only touch a fraction of the sheet.
Prepare the file — this is where most errors start
More wrong answers come from the CSV than from the model. Before you upload:
- One header row, at the top. No merged cells, no two-line headers, no title row above the header.
- Strip currency symbols and thousands separators.
$1,240is text;1240is a number. Anything formatted as text sorts and sums wrong. - Use ISO dates —
2025-03-14. Local formats are ambiguous, and03/04/2025is a different day depending on who reads it. - Delete totals rows inside the data. A "Total" row gets summed along with everything else and quietly doubles your answer.
- Remove blank spacer rows and stray notes. They become empty records.
- Give columns plain names.
revenue, notRevenue ($) *net.
Ask the question properly
- Name the columns exactly as they appear. "Sum
revenuewhereregionis North" beats "how much did the north make". - Ask for one number at a time. Compound questions produce compound errors, and you can't tell which half went wrong.
- Say the period explicitly. "In 2025" — not "last year", which depends on when the model thinks today is.
- Ask it to show its working. "Show the query you ran" turns an unverifiable answer into a checkable one.
- Ask for a row count alongside the total. If you expect 12 months and it used 13 rows, something is off — probably that totals row.
Verify before you trust
Three checks, thirty seconds:
- Read the query. Does the filter say what you meant? Wrong column, wrong date
range, missing
WHERE— all visible at a glance. - Check the row count against what you expect the answer to cover.
- Spot-check one row you can verify by eye against the original sheet.
If a tool won't show you a query, treat every number it gives you as an estimate. That's not cynicism — it's the honest reading of how the answer was produced.
How Relaite does it
This is the approach above, built in. A CSV attached to an agent is stored as a table, not
chunked into text. When a question needs it, the model writes one SELECT and
Relaite runs it against a throwaway read-only SQLite database:
- A single
SELECTstatement only — no writes, no attaching files, no extensions - Row-capped results and a five-second deadline, so a bad query can't hang the chat
- Currency symbols and separators stripped on the way in, dates normalised to ISO
- The whole file is queried, regardless of length — nothing is sampled
Which means the number in the reply was computed by a database, and asking "show the query you ran" gets you a real one.
Try it without uploading anything. A new Relaite account comes with a sample-data agent that already has a sales spreadsheet attached. Ask it "which month had the highest revenue?" or "chart revenue by month" and watch it query rather than guess.
Start free — 25 messages, no card. Then add your own CSV and ask it the same way.
Common questions
- Why does ChatGPT get my spreadsheet totals wrong?
- Usually because it never saw the whole file. Long tables get truncated or sampled to fit the context window, and whatever survives is then added up by a language model rather than by a calculator. The answer looks confident either way, which is what makes it dangerous.
- How do I make an AI model compute instead of estimate?
- Make it write code or SQL and have something else run it. The model is good at turning your question into a query and bad at being the query engine. Any tool that shows you the query it ran is doing this; if you cannot see a query, assume the number was estimated.
- How do I check an answer I have been given?
- Ask for the query it ran and read it. Then ask for a count of the rows involved and check it against what you expect, and spot-check one row you can verify by eye. If a tool will not show you the query, treat the number as a guess.
- What breaks a CSV before the model even sees it?
- Currency symbols and thousands separators that turn numbers into text, dates written in a local format, a totals row sitting inside the data, merged or two-line headers, and blank rows used as spacing. Fix those in the sheet and most wrong answers disappear.