Skip to content

How to check an AI-generated Excel or Google Sheets formula

Guides
A brass measuring tool spans the gap between two blocks in a row of wooden blocks.
AI-generated editorial illustration.
The fastest way to check an AI-generated formula is to give it two rows that look almost identical but should get different treatment. A single well-chosen counterexample can expose a missing condition that stays invisible in a thousand rows of ordinary orders.

Give the assistant a business rule it can get wrong

Imagine a distributor owes a rebate on paid West-region orders of at least $100. You want the dollar value of qualifying orders, before applying the rebate percentage. This sentence fixes three tests and the unit of the answer. If the prompt only says “calculate the rebate,” an assistant might count orders, total every paid invoice or invent a percentage.
Create an empty Excel or Google Sheets file with Region, Status and Amount in A1:C1. Enter the five orders below in that sequence.
RegionStatusAmount
WestPaid100
WestPending140
EastPaid160
WestPaid99
WestPaid125
Only rows two and six qualify. Their amounts total $225. The $100 item belongs because the rule says “at least.” The $99 item supplies a deliberately close counterexample.
Ask the assistant for one formula using the English function names and US separators. Give it the column letters, first and last data row, and the rule. Request a one-sentence explanation of each condition. If the range is tiny, the assistant does not need the live sales file. A schema and a handful of invented rows provide enough detail to critique the expression.

Compare the proposed expression with the qualifying rows

A suitable answer is =SUMIFS(C2:C6,A2:A6,"West",B2:B6,"Paid",C2:C6,">=100"). The first range supplies the amounts. Each subsequent pair applies a test to the same five rows. Microsoft's SUMIFS reference is particularly helpful if the assistant puts the range to add at the end, borrowing the argument order from SUMIF.
Trace the expression with your finger before filling it down another sheet. If the final comparison is greater than $100, the answer falls to $125. If the formula forgets the status test, the pending $140 slips in and the answer rises to $365. Those wrong answers are diagnostic. They tell you which part to inspect without asking the same assistant to grade its own output.

Test the version you will actually reuse

Copy the sample and change just one input at a time. Switching the East order to West should produce $385. Restore it, then change the West pending order to Paid. Expect $365. Change the $99 to $100 in the original sample and expect $325. These three experiments exercise region, status and the threshold independently. Save the expected values as typed numbers beside the outputs so the tests cannot inherit the same formula error.
For a reusable report, place the minimum amount in F2. Replace the last criterion with ">="&$F$2. Raise F2 from 100 to 101 to check that the $100 order drops out. Keep the amount as a number in the cell. If a localized spreadsheet expects different separators or function names, use that application's formula editor to translate the syntax before concluding that the business rule is faulty.
A generated workbook deserves the same inspection as a formula copied from chat. Our guide to creating an Excel file with Gemini covers the file-generation step. Keep the test rows on a separate tab in the delivered file so the next person can rerun them after changing the sales rules.
loading

Loading