How to Use the REDUCE Function to Iterate Over an Array in Excel

The Limitation of Standard Aggregation

In Microsoft Excel, standard aggregation functions like SUM or AVERAGE are simple: you give them a massive array of numbers, and they collapse that entire array down into a single result. If you want to add 100 cells together, =SUM(A1:A100) gets the job done instantly.

However, these basic functions are entirely static. What if you need to perform a highly complex, custom mathematical operation on every single cell as it is being aggregated? What if you are building an advanced financial model that needs to compound an initial investment amount row-by-row through an array of variable interest rates?

You cannot use a standard SUM or PRODUCT function for this. In the past, this required writing a complex VBA macro loop. Today, you can use Excel’s native REDUCE function.

Understanding the Syntax

The REDUCE function is a dynamic array “Helper Function.” It iterates through an array of data, one cell at a time, performing a custom LAMBDA calculation on each cell, and carrying the accumulated total forward until the array is finished.

=REDUCE(initial_value, array, LAMBDA(accumulator, current_value, calculation))

  • initial_value: The starting number for your calculation (e.g., a starting bank balance of $10,000).
  • array: The range of data you want to loop through (e.g., a column of 12 monthly interest rates).
  • LAMBDA: The custom formula. It must contain two variables: the accumulator (the running total) and the current_value (the specific cell the loop is currently looking at).

Example 1: Basic Accumulation

To understand the logic, let’s use REDUCE to recreate a basic SUM function. Assume you have the numbers 1, 2, and 3 in cells A1:A3.

You want to start with a baseline of 10, and then add the array.

=REDUCE(10, A1:A3, LAMBDA(Total, CellValue, Total + CellValue))

How this works:

  1. Excel starts with the initial_value of 10. It assigns this to the Total variable.
  2. It moves to cell A1 (which contains a 1) and assigns it to the CellValue variable.
  3. It runs the calculation: 10 + 1 = 11.
  4. Crucial step: It loops back around. The Total is now permanently updated to 11.
  5. It moves to cell A2 (which contains a 2). It runs the calculation: 11 + 2 = 13.
  6. It loops back. The Total is now 13.
  7. It moves to cell A3 (which contains a 3). It runs the calculation: 13 + 3 = 16.
  8. The array is empty. The function terminates and outputs 16 to the screen.

Example 2: Complex Financial Compounding

The true power of REDUCE is unlocked when dealing with compounding logic.

Assume you have a starting investment of $5,000. In cells B1:B5, you have five different annual percentage yields (APYs): 5%, 7%, -2%, 4%, and 8%.

You want to calculate exactly how much money you will have after 5 years, assuming the growth compounds on the new total every single year. You cannot simply multiply the percentages. You must loop through them sequentially.

=REDUCE(5000, B1:B5, LAMBDA(Balance, Rate, Balance * (1 + Rate)))

How this works:

  1. Year 1: 5000 * (1 + 0.05) = $5,250.
  2. Year 2: 5250 * (1 + 0.07) = $5,617.50.
  3. Year 3: 5617.50 * (1 - 0.02) = $5,505.15.

The function continues to carry the Balance forward, compounding it perfectly row-by-row until it reaches the end of the 5-year array, spitting out the final, mathematically perfect total.

Advanced String Concatenation

REDUCE is not limited to math; it can also accumulate text strings.

If you have a column of 10 employee names and want to instantly generate a single, comma-separated sentence (e.g., “John, Mary, Steve”), you can use REDUCE to stitch the text together dynamically:

=REDUCE("Team:", A1:A10, LAMBDA(Sentence, Name, Sentence & " " & Name & ","))

This allows for complex, logic-based text formatting without requiring messy TEXTJOIN workarounds.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.