Create advanced Works with: Any AI

LET and LAMBDA for Readable Formulas

Structured brief Has example

Name intermediate values and build reusable functions.

The Open buttons send the prompt text as currently shown below to that site only when you click. Fill in the placeholders first.

Rate this prompt

Loading ratings…

Show me how to use LET and LAMBDA in my spreadsheet. App and version (they may not be available in older versions): [SPREADSHEET_APP_AND_VERSION]. A long formula I want to improve: [PASTE_FORMULA]. Calculations I repeat often: [REPEATED_CALCULATIONS].

Provide:
1. Rewrite my formula with LET: names for repeated parts and intermediate results. Example pattern: =LET(price, B2, qty, C2, subtotal, price*qty, tax, subtotal*Inputs!$B$1, subtotal+tax).
2. Explanation of how names are evaluated, scope, and the benefit (readability and performance when the same calculation is reused).
3. A LAMBDA example for a function I repeat (for instance a commission calculation) with parameters, naming it in the name manager so it can be called like =COMMISSION(B2), and documenting parameters in the description.
4. Helper functions that take LAMBDA (MAP, REDUCE, SCAN, BYROW, BYCOL) with one example each from my context.
5. Testing: how to verify equal results against the original on at least five cases.
6. Compatibility: the fallback for older versions or for people who use other apps, and the risk of sharing files that depend on named functions.
7. Style rules: descriptive names, one idea per name, avoid over-engineering.

Do not change the logic of my formula. Warn me when the workbook will be read by people on older versions.

Fill in before use

Optional: type your details and the prompt above updates. Nothing is saved or sent.

Replace each bracketed placeholder with your own details, then paste into Any AI or another assistant.

See an example result (fictional data)
Before: =(B2*C2)+(B2*C2)*Inputs!$B$1
After: =LET(price, B2, qty, C2, subtotal, price*qty, tax, subtotal*Inputs!$B$1, subtotal+tax)
Reusable function (name COMMISSION in the name manager): =LAMBDA(sales, rate, MAX(0, sales)*rate) called as =COMMISSION(B2, 0.05).
Helper: =MAP(B2:B10, LAMBDA(x, x*1.2)).
Tests: price 10, qty 3, tax 0.2 returns 36 in both versions. Compatibility: older versions show #NAME?; document the dependency for anyone opening the file. Style rules: descriptive names, one idea per name, and no over-engineering. Verify at least five cases against the original formula before replacing it, and keep a copy of the old formula in a note.

Illustrative only, made-up data. Your results will differ and must be reviewed.

Related prompts