REDUCE

Formulas / REDUCE
Reduce an array.
=REDUCE([initial_value], array, lambda)
  • initial_value - [OPTIONAL] the initial value for the accumulator
  • array - REQUIRED the array to be reduced
  • lambda - REQUIRED the custom LAMBDA function

Examples

  • =REDUCE(0,{1,2,3,4,5},LAMBDA(a,b,a+b))

    This example demonstrates the simplest use of the REDUCE function. It adds all values in a list of numbers using the formula. In this example, the REDUCE function returns 15.

  • =REDUCE(1,{1,2,3,4,5},LAMBDA(a,b,a*b))

    The REDUCE function can also be used for multiplication. This formula multiplies all values in a list of numbers and returns 120.

Summary

The REDUCE function is used to reduce an array by applying a LAMBDA function to each value. The LAMBDA takes three arguments and the result is returned as the accumulated value with an initial_value set as the starting value.

  • The REDUCE function applies a custom LAMBDA function to each element in a given array and returns the sum of results to a single value, making it a useful tool for processing and returning a single value.


Frequently Asked Questions

What is the REDUCE function?
The REDUCE function is a powerful JavaScript array method that applies a custom LAMBDA function to each element in an array, optionally reducing its size. It can be used to process each element in an array row by row, and returns a single value if the input values are equal.
What are some uses for the REDUCE function?
The REDUCE function can be used for a variety of tasks, including:
  • Calculating conditional sums and counts, such as SUMIFS and COUNTIFS.
  • Processing each element in an array and returning a new array of results.
  • Calculating a final accumulated result.
  • Using a named LAMBDA to manage the logic in one location.
How do I use the REDUCE function?
Using the REDUCE function is relatively straightforward. First, you'll need to create a custom LAMBDA function that you want to apply to each element in the array. Then, you can use the REDUCE method to apply the LAMBDA to each element in the array, optionally reducing the size of the array.

Make Better Decisions
With Data

Analyze data, automate reports and create live dashboards
for all your business applications, without code. Get unlimited access free for 14 days.