Data & BI

Verified against ChatGPT · 2026-08-09

Get an Excel formula that survives contact with your actual messy spreadsheet, not just the happy path

Builds an Excel formula for a specific calculation and explicitly stress-tests it against blanks, text-in-number-columns, and merged cells before handing it back, so it doesn't break the moment it hits real data.

ChatGPT (GPT-5.1)4 fillable variables

The prompt

Ready to copy — highlighted parts are example details you can swap.

Act as a senior data analyst who has been burned before by Excel formulas that work perfectly in a demo and break the moment someone opens the real workbook. Build me a formula for the task below, and stress-test it before handing it back.

WHAT THE FORMULA SHOULD CALCULATE
The average order value for each region, excluding any orders marked as refunded, ignoring blank rows.

COLUMN LAYOUT
Column B = region, Column D = order status, Column F = order amount, data starts row 2, roughly 3,000 rows.

EXCEL VERSION
Microsoft 365 desktop, so dynamic array functions like FILTER and UNIQUE are available.

KNOWN MESSINESS IN THE SHEET
Column D sometimes has 'Refunded' and sometimes 'refunded' typed manually, and roughly 40 rows have a blank order amount pending finance entry.

Do the following in order:
1. Write the formula.
2. Stress-test it yourself, in writing, against these specific failure modes before presenting it as final: blank cells in any referenced range, text accidentally sitting in a numeric column, a #N/A or #REF! propagating from an upstream cell, and (if relevant to the version given) whether it needs to be an array formula or will spill automatically.
3. If the formula as first written would break under any of those conditions, revise it and show the fixed version, explaining what changed and why.
4. Note any behavior difference if this workbook might later be opened in an older Excel version or Google Sheets.

WHAT NOT TO DO
Do not hand back a formula that only works on clean, complete data without saying so — if a genuinely more robust version exists but is meaningfully more complex, give me both and let me choose, rather than silently picking simplicity over robustness or vice versa.

OUTPUT FORMAT
1. Final formula, ready to paste, with cell references matching the column layout given.
2. Plain-English explanation of what it does, one sentence per logical part.
3. Stress-test results: which failure modes it now handles and how, listed explicitly.
4. Compatibility note (older Excel / Google Sheets), only if relevant.

Customize

Optional — swap in your own details for the highlighted parts above.

Why this works

The explicit stress-test step matters because a model asked to just "write a formula" optimizes for the shortest formula that satisfies the stated goal on the assumption of clean input, since that's the pattern most represented in generic examples it's drawing on — nothing about a bare request signals that the sheet is messy, so nothing pushes the model to defensively handle blanks or stray text. Naming the specific failure modes (blank cells, text-in-numeric-column, propagated errors, array/spill behavior) rather than saying "make it robust" matters because "robust" is exactly the kind of unfalsifiable instruction that gets nominally satisfied without changing the actual formula — a model can claim a formula is robust while it still divides by a blank cell and returns #DIV/0!. Requiring the version-specific check on spill behavior versus array formulas addresses a genuine compatibility trap: a formula written assuming Microsoft 365's dynamic arrays will look identical in syntax but behave completely differently (or error outright) in an older desktop version or when the workbook is opened in Google Sheets, and this is exactly the kind of environment detail a model won't proactively flag unless the version is both requested and used as a checkpoint. Offering both a simple and a more defensive version when they diverge meaningfully respects a real trade-off — sometimes a three-nested-function robust formula is genuinely worse for a spreadsheet three other people will edit by hand, and the choice of which to keep belongs to the person who knows their team, not to the model defaulting silently to whichever it finds more impressive.

What you get back

=IFERROR(AVERAGEIFS(F2:F3000,B2:B3000,"Region A",D2:D3000,"<>*refund*",F2:F3000,"<>"),"No data") — this excludes blanks in the amount column, matches 'Refunded' case-insensitively via a wildcard-style filter approach, and returns a clear 'No data' label instead of a #DIV/0! error if a region has zero qualifying rows. Stress test: blanks in F handled via the exclusion condition; mixed-case 'refunded'/'Refunded' handled since AVERAGEIFS criteria matching is case-insensitive by default; propagated #N/A from upstream would still break this — recommend wrapping upstream lookup cells in their own IFERROR first.

Verified against

ChatGPT GPT-5.1 · 2026-08-09

Changelog

  • 2026-08-09 Initial publish, verified against ChatGPT GPT-5.1.

Need this built into your business?

If a prompt isn't enough — what Scult builds, built and maintained for you — that's Scult's day job.

EXPLORE WHAT SCULT BUILDS
All Data & BI prompts

Check your AI visibility

One URL in, a 0–100 score and the exact fixes out.

RUN THE CHECK

Browse all the tools

15 tools across six categories
13 of them never send your data anywhere

Free · No signup · No trial clock

SEE THE DIRECTORY