Looping With MAP and REDUCE
Apply a LAMBDA across an array to transform or accumulate values.
Looping Without Code
Sometimes you want to apply the same calculation to every value in a range, or boil a whole range down to a single number. In programming this is a loop. In modern spreadsheets, MAP and REDUCE do this for you using LAMBDA.
- MAP transforms each element of an array into a new element
- REDUCE combines all elements into one accumulated result
Both take a LAMBDA that describes what to do with each value. They are available in Microsoft 365 and Google Sheets.
How MAP Works
MAP walks through an array and applies a LAMBDA to each item, producing a new array of the same size. The LAMBDA's parameter receives one element at a time.
The pattern is: give MAP the array, then a LAMBDA whose parameter stands for each value. MAP spills the transformed results across cells automatically.
=MAP(array, LAMBDA(value, calculation))All lessons in this course
- Naming Steps With LET
- Defining Custom Functions With LAMBDA
- Looping With MAP and REDUCE
- Cleaner Formulas With Named LAMBDAs