Category: FUNCTION | Updated: 2026-11-22
How to Use the SCAN Function in Google Sheets | Calculate Running Totals and Cumulative Progress
What Is the SCAN Function?
The SCAN function processes each element of an array in order while performing a cumulative calculation, and returns an array containing all intermediate values. It lets you compute daily or monthly running totals of sales, or track inventory balances over time, with a single spilling formula.
Syntax
=SCAN([initial_value], array, LAMBDA(accumulator, current_value, formula_expression))
- initial_value: [Optional] The starting value for the cumulative calculation (e.g.,
0). If omitted, the first element ofarrayis used. - array: The cell range or array to scan sequentially.
- LAMBDA(accumulator, current_value, formula_expression):
- accumulator: The variable holding the cumulative result up to the previous step.
- current_value: The variable holding the value of the cell currently being processed.
- formula_expression: The formula that computes the next cumulative value.
Example
Here is an example of using SCAN in cell C2 to calculate the running total of monthly sales from B2:B5.
| Row | Column A (Month) | Column B (Monthly Sales) | Formula in Column C | Column C (Running Total) |
|---|---|---|---|---|
| 1 | Month | Monthly Sales | Running Total | Running Total |
| 2 | Apr | 100 | =SCAN(0, B2:B5, LAMBDA(acc, cur, acc + cur)) |
100 |
| 3 | May | 150 | (Auto-spilled) | 250 |
| 4 | Jun | 120 | (Auto-spilled) | 370 |
| 5 | Jul | 200 | (Auto-spilled) | 570 |
Common Errors and Notes
- Behavior with Blank Cells: If there are blank cells (treated as
0) at the bottom of the range, the same running total repeats down to the last row. To keep unentered rows blank, you can add a conditional check like=SCAN(0, B2:B5, LAMBDA(acc, cur, IF(cur="", "", N(acc) + cur)))—usingN(acc)prevents a#VALUE!error if a blank row appears in the middle and turnsaccinto an empty string. #REF!Error: Because the result spills as an array, a#REF!error occurs if any cell in the output range already contains a value.
Frequently Asked Questions
Q. What is the difference between SCAN and REDUCE?
A. REDUCE returns only the single final result after processing all elements, whereas SCAN outputs an array containing every intermediate step (such as the running total at each row).
Q. What happens if I omit the first argument, initial_value, in SCAN?
A. If omitted, the first element of the array is used as the initial value. When calculating numeric running totals, it is safer to explicitly specify 0.