Subscribe free
AI at work3 min readAdvanced

Analyse data with AI’s code tools, and check the working

Let an assistant write and run code on your spreadsheet, then check its working. A workflow for analysis you can trust, and rerun next month.

3 min read 1:11 video with captions
Video transcript

Upload a spreadsheet, ask a question and get an answer in seconds. Here’s how to make sure that answer is actually right.

Assistants with a code tool don’t do sums in their heads. They load your file, write a short program, run it in a sealed-off space, and report what it found.

The arithmetic is reliable. The risk is in the choices the code makes: which rows it kept, how it read each column, and what it assumed.

So before any answers, ask for a profile of the data: how many rows and columns, what type each column is, what’s missing, and the range of dates it found.

Watch for the classic traps: misread columns, rows quietly dropped, dates read month first, averages that hide the detail, and patterns mistaken for causes.

Ask it to show its code and list every assumption. Then reconcile: the row counts and totals should match your original file before you trust a single chart.

Once it checks out, save the code. Next month you can rerun the same analysis on new data, and a colleague can see exactly what was done.

Take out personal data, use an approved tool, and copy the prompts from the full guide below.

In 30 seconds

  • Ask for a profile of the data first: rows, columns, blanks and how it read each one.
  • Reconcile before you believe: row counts and totals should match the source file.
  • Save the code, so the analysis can be checked and rerun on next month’s data.

Ask a chatbot to total a column in its head and it can simply get it wrong. Give the file to an assistant with a code tool and it writes a short program, runs it and reports back. That’s far more reliable, but only if the program does what you think. New to this? Start with AI for spreadsheets.

What happens when you upload a file

Several assistants, including ChatGPT, Claude and Gemini, can load a spreadsheet or you upload, write code for your question, usually in , and run it in a . Inside Excel, Microsoft Copilot can analyse the data in your workbook.

  1. LoadReads your file into a table
  2. WriteWrites code for your question
  3. RunRuns it in a sandbox
  4. ReportTurns the output into an answer
What a code tool does with your question. The answer is only as good as the code’s choices.

The arithmetic is now done by code, so it’s reliable. The risk moves to the choices the code makes: which rows it kept, how it read each column, and what it assumed when the data was ambiguous. Those choices often go unmentioned unless you ask.

A workflow you can trust

  1. Describe the dataSay what one row is, such as an order or a line item, what each column means, the units, and how blanks are marked.
  2. Ask for a profile firstBefore any answers: rows and columns, each column’s type, missing values, duplicates and the range of dates it found.
  3. Ask one question at a timeIn plain English. Say how to treat awkward cases, such as refunds, test orders or blank regions.
  4. See the workingAsk for the code, or the formula, and a list of every assumption and filter it used.
  5. ReconcileRow counts and totals should match the source file. If rows went missing, find out where.
  6. Then chart itOnce the numbers check out, ask for charts with clear titles and units on the axes.
  7. Save the codeKeep it with the file, so you or a colleague can check it and rerun it on next month’s data.
Profile the data first

I’ve uploaded [file name], an export of [what it is]. Each row is [one order, one line item or one customer]. Before answering anything, profile it: number of rows and columns, each column’s data type, missing values per column, duplicate rows, and the earliest and latest dates. Tell me whether you read the dates as day first or month first, and flag any column you’re unsure about. Don’t remove or change any rows yet.

Answer, and show the working

Now answer this: [your question]. Show the code you ran. List every assumption and filter, and how many rows each step kept or removed. Finish with a check I can do myself: the row count and the total of [column] in the original file, and in the data you used.

If the two totals differ, ask it to list the rows that explain the gap.

Five ways a tidy answer goes wrong

  • Misread columns“Amount” might include VAT, or “date” might be the order date, not the delivery date. Say what each column means.
  • Rows quietly droppedBlank categories can vanish from a grouped total, and numbers stored as text, such as “1,200”, can be skipped. Compare row counts.
  • Dates and unitsA common Python tool reads 03/04/2025 as 4 March unless told otherwise. Check units too: pounds or thousands of pounds.
  • Averages that hide thingsOne huge order can drag an average up, and an overall trend can reverse within groups. Ask for the and a breakdown.
  • Correlation isn’t causeSales rose after the new website launched, but it was also peak season. A doesn’t show why. Ask what else could explain it.

None of these raises an error. The code runs, the chart looks fine and the number is wrong. That’s why reconciling against the source matters more than rereading the answer.

Keep personal data out

Before you upload, remove what the question doesn’t need: names, contact details and free-text notes, where personal details often hide. Swapping names for ID numbers helps, but if the IDs can be linked back to people, the data can still count as personal data under .

Use a tool your organisation has approved, on a work account. Your file goes to the provider to be analysed, and one provider warns that hidden instructions in a file could trick its assistant into sending data out. For the basics, see using AI at work safely.

Check yourself

3 quick questions nothing is saved
1What should you ask for before any answers?

2The assistant’s total is lower than your source file’s. What should you suspect first?

3Sales rose in the months you posted more on social media. What does that show?

Up next in AI at work

Advanced3 min read

Write an AI policy your team will actually follow

A short, practical AI policy beats a long one nobody reads. What to cover, from approved tools and data rules to accountability, and how to keep it current.

More guides

Get AI explained at your level, every weekday

The five stories that matter, in plain English, plus a new guide each week. Free.