Skip to content

REDUCE

Walks through an array one value at a time, carrying a running result called the accumulator, and returns its final value.

Syntax

=REDUCE(, , )

LAMBDA and LET

Excel for Microsoft 365, Excel 2024 and later, and Excel for the web. Not available in Excel 2021 or earlier.

Try it

Edit the formula in D2 or change the inputs. The sheet recalculates as you type.

D2
A
B
C
D
E
1
Amount
Item
2
120
Gloves
680
3
85
Tape
4
240
Pallet wrap
5
60
Labels
6
175
7
8

D2 =REDUCE(0,A2:A6,LAMBDA(acc,v,acc+v)) returns 680

How REDUCE works

REDUCE collapses an array into one result by visiting each value in turn. At each step a LAMBDA combines the result so far, the accumulator, with the next value, and returns the new accumulator. When the values run out, REDUCE returns the last accumulator.

The arguments

  • initial_value is what the accumulator holds before the first value. Use 0 for a sum or count, 1 for a product, "" to build text.
  • array is the data to walk through. A range is read across each row, left to right, and then down.
  • lambda takes two parameters. Name them as you like: LAMBDA(acc,v,acc+v) has acc for the accumulator and v for the current value.

=REDUCE(0,A2:A6,LAMBDA(acc,v,acc+v)) starts at 0 and adds each amount in turn. The result is 680, the same as SUM, which is the simplest way to see how it works.

Where REDUCE earns its place

SUM, MAX and COUNTIF cover the simple cases, so reach for REDUCE when the calculation has state that a single function can't hold:

  • Counting with a rule. =REDUCE(0,A2:A6,LAMBDA(n,v,n+(v>100))) counts amounts over 100. The comparison returns TRUE or FALSE, which add as 1 or 0.
  • Joining text with your own rules. =REDUCE("",B2:B5,LAMBDA(a,v,IF(a="",v,a&", "&v))) builds a list with commas and no leading comma.
  • Tracking the best so far. =REDUCE("",B2:B5,LAMBDA(a,v,IF(LEN(v)>LEN(a),v,a))) returns the longest item.
  • Compounding. A balance that grows by a different rate each period is a REDUCE, because each step depends on the last.

REDUCE or SCAN

REDUCE returns only the final value. SCAN uses the same arguments but returns the accumulator after every step, such as a running total. If you want to see the work, use SCAN. If you only want the answer, use REDUCE.

Notes

The LAMBDA is called once for each value, so a very large array makes many calls. If a built-in function does the job, such as SUMIFS or TEXTJOIN, it will be faster and easier to read. The accumulator can be a number, text or a logical value.

An error in the array passes through the LAMBDA like any other value, and usually turns the final result into an error. See LAMBDA for writing the function and MAP for applying one to each item without accumulating.

REDUCE needs Microsoft 365, Excel 2024 or later, or Excel for the web.

Arguments

initial_valueoptional
The starting value of the accumulator, such as 0 for a total, 1 for a product or "" for text. It is best to supply it, so the first step is clear.
array
The range or array to walk through, left to right and then down.
lambda
A LAMBDA with two parameters: the first receives the accumulator, the second the current value. Whatever it returns becomes the accumulator for the next step.

Examples

Each example is a live sheet. Change the inputs or the formula and watch the result.

Example 1

Add the values, one step at a time

D2 =REDUCE(0,A2:A6,LAMBDA(acc,v,acc+v))

Result: 680

The accumulator goes 0, 120, 205, 445, 505, 680. It is the same answer as SUM, which shows what REDUCE does.

D2
A
B
C
D
E
1
Amount
Item
2
120
Gloves
680
3
85
Tape
4
240
Pallet wrap
5
60
Labels
6
175
7
8

D2 =REDUCE(0,A2:A6,LAMBDA(acc,v,acc+v)) returns 680

Example 2

Count the amounts over 100

D2 =REDUCE(0,A2:A6,LAMBDA(n,v,n+(v>100)))

Result: 3

120, 240 and 175 are over 100. The comparison v>100 is TRUE or FALSE, which adds as 1 or 0.

D2
A
B
C
D
E
1
Amount
Item
2
120
Gloves
3
3
85
Tape
4
240
Pallet wrap
5
60
Labels
6
175
7
8

D2 =REDUCE(0,A2:A6,LAMBDA(n,v,n+(v>100))) returns 3

Example 3

Join text with commas, and no comma at the start

D2 =REDUCE("",B2:B5,LAMBDA(a,v,IF(a="",v,a&", "&v)))

Result: Gloves, Tape, Pallet wrap, Labels

The IF avoids a comma before the first item, when the accumulator is still empty.

D2
A
B
C
D
E
1
Amount
Item
2
120
Gloves
Gloves, Tape, Pallet wrap, Labels
3
85
Tape
4
240
Pallet wrap
5
60
Labels
6
175
7
8

D2 =REDUCE("",B2:B5,LAMBDA(a,v,IF(a="",v,a&", "&v))) returns Gloves, Tape, Pallet wrap, Labels

Example 4

Find the longest item

D2 =REDUCE("",B2:B5,LAMBDA(a,v,IF(LEN(v)>LEN(a),v,a)))

Result: Pallet wrap

At each step the accumulator keeps whichever of the two is longer. Pallet wrap has 11 characters.

D2
A
B
C
D
E
1
Amount
Item
2
120
Gloves
Pallet wrap
3
85
Tape
4
240
Pallet wrap
5
60
Labels
6
175
7
8

D2 =REDUCE("",B2:B5,LAMBDA(a,v,IF(LEN(v)>LEN(a),v,a))) returns Pallet wrap

Example 5

The biggest value in a block

E1 =REDUCE(0,A1:C3,LAMBDA(m,v,MAX(m,v)))

Result: 77

REDUCE reads a block across each row, left to right, and then down. MAX keeps the larger of the best so far and the next value.

E1
A
B
C
D
E
F
1
12
45
8
77
2
31
19
77
3
5
64
23
4
5
6

E1 =REDUCE(0,A1:C3,LAMBDA(m,v,MAX(m,v))) returns 77

Your turn.

Solve it in the sheet. Every answer is checked, with hints if you need them.

Task 1 of 2

In D2, multiply all the factors in A2:A5 together using REDUCE. Start the accumulator at 1.

Answer in D2.

D2
A
B
C
D
E
F
1
Factor
Step
2
2
Plan
3
3
Build
4
4
Test
5
5
Ship
6
7
8

Common mistakes

  • Choose the initial value to suit the job. 0 for a total, 1 for a product, "" for text. A product that starts at 0 is always 0.
  • The first LAMBDA parameter is the accumulator and the second is the current value. If you swap them, the formula still runs but gives a wrong answer.
  • The LAMBDA must return a value of the same kind as the accumulator, or a later step can fail. Adding text to a number gives #VALUE!.
  • REDUCE returns one result. To see the running values, use SCAN.
  • For plain totals, counts and joins, SUM, COUNTIF and TEXTJOIN are shorter and quicker. Use REDUCE when the logic needs state.

Questions people ask

What does REDUCE do in Excel?

It applies a LAMBDA to every value in an array, passing along a running result, and returns the final result. It is the general form of sums, products and joins.

What is the difference between REDUCE and SCAN?

They take the same arguments. REDUCE returns only the final accumulator, and SCAN returns the accumulator after every step, as an array the same size as the input.

What should I use as the initial value?

The value that does nothing when combined with your first item: `0` for adding, `1` for multiplying, and `""` for joining text.

In what order does REDUCE read a range?

Across each row from left to right, then down to the next row. For a single column it simply runs from top to bottom.

Does REDUCE work in Excel 2021?

No. It is available in Microsoft 365, Excel 2024 and later, and Excel for the web. Earlier versions return `#NAME?`.

Learn REDUCE in a real sheet.

Tracks take you from the basics to modelling, one graded exercise at a time.