New Tool Radar

AI for Data & Spreadsheets

How to Check an AI Formula with Nested IF Logic in Excel

Check an AI-written nested IF formula by testing every branch against a hand-worked table of cases.

Schematic illustration for How to Check an AI Formula with Nested IF Logic in Excel: three numbered steps - List every branch; Test one row per branch; Check the boundary values.

A nested IF that grades scores or bands discounts has one branch per outcome, and an AI can easily put a boundary in the wrong place, so a score of 70 lands in the wrong band. Testing one row per branch, plus the exact boundary values, proves each outcome before the formula is used.

Prerequisites

  • Excel
  • The AI-written nested IF formula and the rule it should follow
  • A copy of the source file, so the original stays untouched.

Steps

  1. Write the rule out in plain words first, with each band and its exact boundary, for example 70 and above is a pass.
  2. Build a small test table with one row per branch, plus one row on each boundary value.
  3. Paste the AI formula beside the test table and compare its result with the expected result for every row.
  4. If a boundary row fails, read the comparison operator in that branch of the formula and fix it, then re-test all rows.
  5. Keep the test table on a separate sheet in the workbook so the formula can be re-tested after any edit.

Worked example: Fictional exam grade bands

The practice table below is a fictional five-student grade test. The band column is the expected result of a nested IF on the score, and the total is the sum of the scores. The table below is fictional practice material, with fictional values. It is the expected result, worked out by hand, not a run of any tool.

Student Score Band
Amara 82 Distinction
Ben 71 Merit
Clara 69 Pass
Dev 58 Pass
Elena 41 Fail
Total 321

Expected result. Five scores, each band matches the rule, and the scores add to 321. UNTESTED: no AI formula was generated for this guide; the table shows the expected values a check should produce.

Limits

  • A nested IF with more than a few branches is hard to read, so consider IFS or a lookup table instead.
  • Boundary values such as exactly 70 must be tested, because that is where off-by-one errors hide.

Sources

See all