Syntax
=MAP(array1, lambda, ...)Arguments
| Argument | Required | Description |
|---|---|---|
array1 | Required | An array or range |
lambda | Required | A LAMBDA with one parameter per array (last argument) |
How to use MAP
When MAP returns more than one value, the result spills into the cells below and to the right. Keep those cells empty, or you get #SPILL!.
MAP takes 2 required arguments, and accepts more values in the same pattern. Type =MAP( in a cell and SheetsBat shows the arguments as you go. Optional arguments are shown in square brackets; leave them out to use their default.
Examples
Each result below was calculated by the SheetsBat formula engine.
=MAP({1,2,3}, LAMBDA(x, x*10))Result Spilled result
| A | B | C | |
|---|---|---|---|
| 1 | 10 | 20 | 30 |
=MAP({1,2}, {3,4}, LAMBDA(a, b, a+b))Result Spilled result
| A | B | |
|---|---|---|
| 1 | 4 | 6 |
Related array functions
- FLATTENPuts the values of one or more ranges into a single column, reading row by row.
- GROUPBYGroups rows by the values of one or more columns and aggregates the values of each group.
- HSTACKPlaces arrays side by side; shorter columns are padded with #N/A.
- MAKEARRAYBuilds an array of the given size by calling a LAMBDA with each row and column number.
- PERCENTOFReturns the sum of a subset of values as a fraction of the sum of all values.
- PIVOTBYSummarizes data by row and column fields and aggregates the values at each intersection.
- QUERYRuns a query (select, where, group by, order by, limit, offset, label) over a range with optional header rows.
- REDUCEReduces an array to one value by applying a LAMBDA to an accumulator and each value.
- SCANApplies a LAMBDA to each value with a running accumulator and returns every intermediate result.