Function · LAMBDA
Excel REDUCE function
The Excel REDUCE function folds an array into one value. Starting from 0, the four utility bills add up to $446.35.
Syntax =REDUCE(initial_value, array, lambda)
=REDUCE(0,A1:A4,LAMBDA(acc,v,acc+v))Arguments
| Name | Required | What to pass |
|---|---|---|
| initial_value | Required | The starting accumulator. For a sum, use 0. It is not included as an extra item from the array. |
| array | Required | The values to fold in, one at a time. |
| lambda | Required | A LAMBDA with two parameters: the accumulator so far, and the next value. It returns the next accumulator. |
Examples
The four utility bills, added with an explicit running total
=REDUCE(0,A1:A4,LAMBDA(acc,v,acc+v))Result $446.35
| A | |
|---|---|
| 1 | 143.60 |
| 2 | 96.20 |
| 3 | 118.45 |
| 4 | 88.10 |
| 5 | 446.35 |
REDUCE walks an array and keeps one running value. Start at 0, add each utility bill, and the finish is $446.35. That is 143.60 + 96.20 + 118.45 + 88.10, the same total behind the average of $111.5875. SUM is shorter when addition is all you want. REDUCE is the form that can carry a different rule, such as a running maximum or a count of bills over $100.
The initial value is the start. It is not spilled and it is not an extra bill. The LAMBDA returns the next accumulator only. SCAN uses the same LAMBDA and spills every step instead of only the last one. MAKEARRAY fills a new grid from the row number and the column number. Excel 2021 does not have REDUCE.