New Tool Radar

AI for Data & Spreadsheets

How to Check Whether an AI-Written LET or LAMBDA Formula Is Readable Enough to Audit

Check an AI-written LET or LAMBDA formula for named values that make it auditable, instead of the same calculation repeated three times.

Schematic with three steps: List every name the formula defines; Check for a calculation written more than; Test the formula with a hand-worked input.

LET names intermediate values so a long formula can reuse them instead of repeating the same calculation, and LAMBDA turns a formula into a reusable function with named parameters. An AI assistant can write a LET or LAMBDA that works but names its values x, y and z, or one that repeats a calculation LET was meant to remove. Read the names before trusting the formula.

What you need

  • The AI-written LET or LAMBDA formula
  • The input values it uses, with their meanings written down
  • A hand-worked answer for one input

Step 1: List every name the formula defines

Read the formula and write down each name LET or LAMBDA defines and what it stands for. A name should say what the value means, such as Rate or Taxable, not just a letter.

Step 2: Check for a calculation written more than once

Search the formula for the same expression appearing twice. If the same calculation is written twice, LET should hold it once under a name; a repeated expression is the main thing LET is for.

Step 3: Test the formula with a hand-worked input

Run the formula on an input whose answer you worked out by hand. If the answer matches, the logic is sound; if it does not, test each named value on its own in a spare cell.

Worked example: synthetic discount calculation

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

Check Value Result
Input price 200 Known price
Discount rate named Rate 10%
Repeated calculation found Price*Rate twice LET should hold it once
Formula result 180 Matches the hand answer

Expected result (UNTESTED). the LET formula returns 180 for a price of 200 at 10%, matching the hand answer, after the repeated Price*Rate calculation is held once under the name Rate. This check was not run live; the table shows the expected result for the synthetic example.

Limits

  • LET and LAMBDA need Microsoft 365 or Excel 2021 or later; older versions show #NAME?.
  • A name that is too short, such as x, hides the meaning as surely as a repeated calculation does.
  • LAMBDA must be called with its arguments in order; a missing argument returns an error, not a partial result.
  • A LET formula that names a value and never uses it is not wrong, but it is a sign the AI left dead code behind.

Sources

See all