MAP, REDUCE and SCAN in Google Sheets: running total, test each row
When ARRAYFORMULA with SUM or AND gives one cell, SCAN builds a running total, MAP checks each row and REDUCE keeps the final value.
On this page
=SCAN(0, C2:C9, LAMBDA(total, x, total + x))Before SUM and AND inside ARRAYFORMULA
| A | B | C | D | E | F | |
|---|---|---|---|---|---|---|
| 1 | Date | Seller | Amount | Running total | Row OK | |
| 2 | Nov 3 | Emily | 42 | 225 | FALSE | |
| 3 | Nov 3 | Jacob | 35 | |||
| 4 | Nov 4 | 18 | ||||
| 5 | Nov 4 | Olivia | 0 | |||
| 6 | Nov 5 | Michael | 27 | |||
| 7 | Nov 5 | Sarah | 50 | |||
| 8 | Nov 6 | David | 31 | |||
| 9 | Nov 6 | Emily | 22 |
What changed
E2SUM to SCANF2AND to MAP
After SCAN in E2, MAP in F2
| A | B | C | D | E | F | |
|---|---|---|---|---|---|---|
| 1 | Date | Seller | Amount | Running total | Row OK | |
| 2 | Nov 3 | Emily | 42 | 42 | TRUE | |
| 3 | Nov 3 | Jacob | 35 | 77 | TRUE | |
| 4 | Nov 4 | 18 | 95 | FALSE | ||
| 5 | Nov 4 | Olivia | 0 | 95 | FALSE | |
| 6 | Nov 5 | Michael | 27 | 122 | TRUE | |
| 7 | Nov 5 | Sarah | 50 | 172 | TRUE | |
| 8 | Nov 6 | David | 31 | 203 | TRUE | |
| 9 | Nov 6 | Emily | 22 | 225 | TRUE |
Type one formula at the top of the column and let it fill the rows under it. For a running total that formula is =SCAN(0, C2:C9, LAMBDA(total, x, total + x)) in E2, and for a TRUE or FALSE on each row it is =MAP(B2:B9, C2:C9, LAMBDA(name, amt, AND(name<>"", amt>0))) in F2. In the take-home copy each one filled eight cells. REDUCE takes the same three arguments as SCAN and hands back only the final step: =REDUCE(0, C2:C9, LAMBDA(total, x, total + x)) returned 225, the last number in the SCAN column. On your own sheet, put your amount range where C2:C9 is, and in MAP list the columns your test reads, with one LAMBDA name for each.
You reach for these three when a formula ought to give one answer per row and gives one answer for the whole range instead. The Broken tab shows exactly that. A small cash log sits in A2:C9 with a date, a seller and an amount on each row. E2 holds =ARRAYFORMULA(SUM(C2:C9)) and F2 holds =ARRAYFORMULA(AND(B2:B9<>"", C2:C9>0)). E2 came back 225, F2 came back FALSE, and E3:F9 stayed empty.
ARRAYFORMULA does not split SUM or AND into rows. Both functions read a whole range and return one value, with or without the wrapper. The lone FALSE says some row failed the test and gives no hint which one.

SCAN keeps every step of a running total, REDUCE keeps the last
SCAN wants a starting value, the range, and a LAMBDA with two names. In the Fixed tab the names are total and x. Sheets starts total at 0, adds the amount in C2, writes 42 in E2, and carries that 42 into the next row. Google's SCAN page calls the first name the accumulator and says it is updated at each step, which is what column E shows: 42, 77, 95, 95, 122, 172, 203, 225. The 95 appears twice because Olivia's amount in C5 is 0.
The names are yours to pick. The first one always holds the running value and the second holds the current cell, whatever you call them, and the page above says a LAMBDA with any other number of names returns #N/A.

H2 on the same tab has the REDUCE version. It returned 225, matching both E9 and the SUM on the Broken tab. For a plain total that makes REDUCE a longer way to write SUM. The extra typing pays off when each step needs a rule SUM can't express, and the REDUCE page has one that adds a price only when it reaches a set amount. Since the two functions take identical arguments, you can build the formula as SCAN first, check every intermediate value in its column, and then change the name to REDUCE to keep just the end result.
| Input | 8 amounts in C2:C9 |
|---|---|
| Formula | =SCAN(0, C2:C9, LAMBDA(total, x, total + x)) |
| Expected | 42, 77, 95, 95, 122, 172, 203, 225 |
| Sheets returned | 42, 77, 95, 95, 122, 172, 203, 225 Matches expected |
| Checked | 2026-11-11, free personal account |
MAP for a test on each row, and open ranges that run past the data
MAP takes one or more ranges and a LAMBDA with one name per range. In F2, B2:B9 feeds name and C2:C9 feeds amt, so on row 4 the LAMBDA sees an empty name and 18. The AND inside it only ever sees one row at a time, which is why it can return a separate answer for each. F4 and F5 came back FALSE. Row 4 has no seller, and row 5 has Olivia with an amount of 0. The other six rows are TRUE. Google's MAP page adds that each value has to map to a single result; a LAMBDA that returns a whole array for one row is not supported.
Columns E and F on the Try it yourself tab still hold the formulas from the Broken tab. Replace E2 with the SCAN formula and F2 with the MAP formula from the top of this page, and E2:F9 should match the Fixed tab cell for cell.
The Whole column tab tries the same formulas on open ranges, the kind people use so new rows are picked up automatically. =SCAN(0, C2:C, LAMBDA(total, x, total + x)) in E2 kept going past the data. E10, E11 and every row below repeat 225, all the way to the last row of the sheet. =MAP(B2:B, C2:C, LAMBDA(name, amt, AND(name<>"", amt>0))) in G2 runs past the data too, and every empty row below it is FALSE, because an empty seller fails the test. F2 keeps the open range and hides the extra rows by wrapping the SCAN in an IF on column C: =ARRAYFORMULA(IF(C2:C="", "", SCAN(0, C2:C, LAMBDA(total, x, total + x)))). F2:F9 match E2:E9, and F10 down are blank. The same IF wrapper on a formula that needs no LAMBDA is in the post on ARRAYFORMULA down a whole column.

The IF wrapper on the Whole column tab blanks a row whenever its amount cell is empty. An amount left empty in the middle of the log would get an empty cell in column F as well, so a row with no money needs a 0 typed in C, the way Olivia's row has one.
Take-home copy. Four tabs: Broken, Fixed, Try it yourself, Whole column. It opens as a copy in your own Drive.