Skip to main content
← All guides

Choose a LAMBDA loop from the result you need

Pair corresponding records, carry one final total or calculate every row-and-column combination.

Original worked example
Posted lineRaw chargeRounded charge
First0.0050.01
Second0.0050.01
Total after line rounding0.010.02

Map corresponding inputs

MAP passes values at the same position from each supplied array to its LAMBDA. In the charge task, qty, rate and adjust belong to one record. The LAMBDA returns one rounded charge for that position, preserving the eight-record source order.

The number and order of local parameters must match the supplied arrays. Local names exist only inside that LAMBDA. Sorting one source column separately would pair quantities with the wrong rates.

=MAP(B2:B9,C2:C9,D2:D9,LAMBDA(qty,rate,adjust,ROUND(qty*rate+adjust,2)))

Reduce to one final state

REDUCE starts with a declared state and updates it for each value. The posted-charge task starts at zero and visits positions 1 through 8, using INDEX to read the status, quantity and rate for the same record. Nonposted records add zero; refunds reduce the total.

Round each selected line before adding it. Eight half-cent lines each round to one cent, giving 0.08. Combining their raw values before rounding would give 0.04. SCAN would expose each intermediate state; this task needs only the final total.

Generate every coordinate

MAKEARRAY calls a LAMBDA for every coordinate of a declared output shape. Its parameters are one-based row and column numbers. The quote task uses the row coordinate to read one carrier and the column coordinate to read one parcel weight, creating all selected combinations.

For each pair, subtract included weight, clamp the excess to zero, round billable excess upward to a half kilogram, price it and add the base fee. Finally round the quote to cents. The prices are fictional teaching inputs. Keep unused output positions clear when the selected dimensions shrink.

Check the rule across sources

Change record order, zeroes, refund signs, posting statuses and matrix dimensions. A formula must keep matching the declared rule, not just the demonstration total. The exercises accept equivalent formulas when the complete values and output extent pass the retained sources.

Numeric precision and bounds are explicit in each task. Text numbers and missing inputs need preparation; they do not silently become valid prices. Workbook downloads preserve current formulas and spill extents or freeze typed results. Native Excel and Sheets recalculation remain separate checks.

Check the idea

Two posted lines each have a raw charge of 0.005. The policy rounds each line to cents before adding. What is the total?

Try the idea

References

Examples and explanations are original. Source links describe the related Excel features; native Excel workbook testing is separate from browser learning checks.