A running product
| A | |
|---|---|
| 1 | Factor |
| 2 | 1 |
| 3 | 2 |
| 4 | 3 |
Formula: C2: =REDUCE(1,A2:A4,LAMBDA(a,x,a*x))
Result: 6
The accumulator starts at 1 and is multiplied by 1, 2 and 3.
REDUCE is a built-in helper in Google Sheets, and it returns a single value from the whole range.
REDUCE(initial_value, array, LAMBDA(total, x))For the running values rather than the final one, use SCAN; MAP returns one result per element.
For a fuller explanation of the arguments and common errors, see the REDUCE Excel guide.
| A | |
|---|---|
| 1 | Factor |
| 2 | 1 |
| 3 | 2 |
| 4 | 3 |
Formula: C2: =REDUCE(1,A2:A4,LAMBDA(a,x,a*x))
Result: 6
The accumulator starts at 1 and is multiplied by 1, 2 and 3.
| A | |
|---|---|
| 1 | Name |
| 2 | Ana |
| 3 | Ben |
| 4 | Cara |
Formula: C2: =REDUCE("",A2:A4,LAMBDA(a,x,a&LEFT(x,1)))
Result: ABC
The first letter of each name is appended to an initially empty text.
| A | |
|---|---|
| 1 | Value |
| 2 | 5 |
| 3 | 20 |
| 4 | 12 |
Formula: C2: =REDUCE(0,A2:A4,LAMBDA(a,x,IF(x>10,a+x,a)))
Result: 32
Only values above 10 are added, so 5 is skipped and 20 + 12 remain.
A tiny spreadsheet with example data. Edit the formula or any number and see the result.
Formula in F2: =REDUCE(0,C2:C7,LAMBDA(a,x,a+x))
| A | B | C | D | E | F | |
|---|---|---|---|---|---|---|
| 1 | Region | Product | Units | Price | Result | |
| 2 | East | Pen | 120 | 2.5 | 350 | |
| 3 | West | Pen | 80 | 2.5 | ||
| 4 | East | Book | 45 | 12 | ||
| 5 | North | Book | 60 | 12 | ||
| 6 | West | Lamp | 30 | 25 | ||
| 7 | East | Lamp | 15 | 25 |
Google Sheets is used here only as a descriptive product name. FormulaCamp is not affiliated with Google.
Enter — commit · F2 — edit · F4 — $ in a reference · Ctrl+C/Ctrl+V — copy and paste · Ctrl+Z — undo
Esc or F6 — leave the sheet for the «Check» button · Shift+Tab in the first cell — back to the page