New Tool Radar

AI for Data & Spreadsheets

How to Check an AI-Written Excel Formula Against a Hand-Worked Sample

Ask an AI tool to draft a formula, then test it on a small hand-worked sample before letting it loose on the real data.

Schematic with three steps: Build the hand-worked sample first; Paste the AI formula beside the sample; Fix the prompt, not just the formula.

Most errors in AI-written formulas are a missing condition that a ten-row sample exposes in minutes. The prompt matters, but the check matters more: name the columns in the prompt, then verify the formula on rows you have already worked out by hand.

What you need

  • Excel with the data in one table, one row per record
  • A hand-worked sample of 8 to 10 rows with the right answers
  • The AI-written formula, pasted into a test cell

Step 1: Build the hand-worked sample first

Pick 8 to 10 rows that cover the edge cases: a zero, a missing value, a refunded row and a normal row. Work out the right answer for each by hand and write it down before testing any formula.

Step 2: Paste the AI formula beside the sample

Put the AI-written formula in a column beside the sample and fill it down. Compare each result with the hand-worked answer, row by row, and mark every row that differs.

Step 3: Fix the prompt, not just the formula

When a row differs, find which condition the formula missed and add it to the prompt: the measure, every condition, where the result goes, and which cells hold dates or rates. Re-run the check on the same sample.

Worked example: synthetic eight-order sample

The table below is a synthetic example. It shows the expected result of checking an AI-written formula; no formula was generated and no sample was run.

Check Count Result
Sample rows hand-worked 8 Source
Formula results matching by hand 7 Pass
Formula results differing 1 Refunded row counted
Hand-worked total 4,320 Formula returns 4,320 after fix

Expected result (UNTESTED). 7 of 8 sample rows match by hand; the formula counts one refunded order, so the prompt gains a Status equals Paid condition and the formula then returns the hand-worked total of 4,320. This check was not run live; the table shows the expected result for the synthetic example.

Limits

  • A formula that passes the sample can still fail on the full data; re-check after loading.
  • Name the columns in the prompt; vague prompts produce vague formulas.
  • Keep the hand-worked sample in the workbook as the test the formula must keep passing.

Sources

See all