Syntax
=SCAN(initial_value, array, lambda)Arguments
| Argument | Required | Description |
|---|---|---|
initial_value | Required | The starting accumulator |
array | Required | The array to go through |
lambda | Required | LAMBDA(accumulator, value) |
How to use SCAN
When SCAN returns more than one value, the result spills into the cells below and to the right. Keep those cells empty, or you get #SPILL!.
SCAN takes 3 required arguments. Type =SCAN( in a cell and SheetsBat shows the arguments as you go. Optional arguments are shown in square brackets; leave them out to use their default.
Examples
Each result below was calculated by the SheetsBat formula engine.
=SCAN(0, {1,2,3}, LAMBDA(a, v, a+v))Result Spilled result
| A | B | C | |
|---|---|---|---|
| 1 | 1 | 3 | 6 |
Related array functions
- PERCENTOFReturns the sum of a subset of values as a fraction of the sum of all values.
- PIVOTBYSummarizes data by row and column fields and aggregates the values at each intersection.
- QUERYRuns a query (select, where, group by, order by, limit, offset, label) over a range with optional header rows.
- REDUCEReduces an array to one value by applying a LAMBDA to an accumulator and each value.
- SEQUENCEReturns a list of sequential numbers in an array of the given size.
- SORTSorts the rows or columns of a range or array.
- SORTBYSorts a range or array by the values of other ranges or arrays.
- SORTNReturns the first n rows of a range after sorting, with options for ties.
- TAKEReturns a number of rows or columns from the start (positive) or end (negative) of an array.