Syntax
=REDUCE(initial_value, array, lambda)Arguments
| Argument | Required | Description |
|---|---|---|
initial_value | Required | The starting accumulator |
array | Required | The array to go through |
lambda | Required | LAMBDA(accumulator, value) |
How to use REDUCE
When REDUCE returns more than one value, the result spills into the cells below and to the right. Keep those cells empty, or you get #SPILL!.
REDUCE takes 3 required arguments. Type =REDUCE( 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.
=REDUCE(0, {1,2,3}, LAMBDA(a, v, a+v))Result =REDUCE(1, {2,3,4}, LAMBDA(a, v, a*v))Result Related array functions
- MAPApplies a LAMBDA to each value of one or more arrays and returns the results.
- 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.
- SCANApplies a LAMBDA to each value with a running accumulator and returns every intermediate result.
- SEQUENCEReturns a list of sequential numbers in an array of the given size.
- SORTSorts the rows or columns of a range or array.
- SORTBYSorts a range or array by the values of other ranges or arrays.
- SORTNReturns the first n rows of a range after sorting, with options for ties.