Sign in with Microsoft
Sign in or create an account.
Hello,
Select a different account.
You have multiple accounts
Choose the account you want to sign in with.

Reduces an array to an accumulated value by applying a LAMBDA to each value and returning the total value in the accumulator.   

Syntax

=REDUCE([initial_value], array, lambda(accumulator, value))

The REDUCE function syntax has the following arguments and parameters:

  • [initial_value]    Sets the starting value for the accumulator.

  • array      An array to be reduced.

  • lambda      A LAMBDA that is called to reduce the array. The LAMBDA takes two parameters:

    • accumulator    The value totaled up and returned as the final result.

    • value     The calculation applied to each element in the array.

Remarks

Use the initial_value argument to set the starting value for the accumulator parameter. In Example 2, where you multiply the accumulator, set the value to 1 to avoid multiplying by 0.

Errors

Providing an invalid LAMBDA function or an incorrect number of parameters returns a #VALUE! error called "Incorrect Parameters".

Examples

Example 1: Sum the squared values

Enter the sample data into cells A1:C2, and then copy the formula into cell D4:

=REDUCE(, A1:C2, LAMBDA(a,b,a+b^2))

First REDUCE function example1

Example 2: Create a customized "PRODUCTIF" function to multiply only values greater than 50

Create a table named "Table2" with one column named "Nums" starting at cell E1. Copy the following formula into cell G2:

=REDUCE(1,Table2[Nums],LAMBDA(a,b,IF(b>50,a+b,a)))

Second REDUCE function example

Example 3: Count only even values

Create a table named "Table4" with one column named "Nums" starting at cell D1. Copy the following formula into cell F2:

=REDUCE(0,Table4[Nums],LAMBDA(a,n,IF(ISEVEN(n),1+a, a)))

Third REDUCE function example

See Also

LAMBDA function

MAP function

SCAN function

MAKEARRAY function

BYCOL function

BYROW function

ISOMITTED function

Need more help?

Want more options?

Explore subscription benefits, browse training courses, learn how to secure your device, and more.

Communities help you ask and answer questions, give feedback, and hear from experts with rich knowledge.

Was this information helpful?

What affected your experience?
By pressing submit, your feedback will be used to improve Microsoft products and services. Your IT admin will be able to collect this data. Privacy Statement.

Thank you for your feedback!

×