Excel functions / Logical

SCAN function

Like REDUCE, but returns every step: a running total, a running maximum and the like.

Syntax

=SCAN(initial_value, array, lambda)

Arguments

When to use it

SCAN works like REDUCE, but spills the running result after every step instead of only the last one. A running total is the classic use, without an expanding SUM in every row.

Examples

  1. A running total

    ABC
    1Sales
    2100100
    3150250
    490340

    In C2: =SCAN(0, A2:A4, LAMBDA(total, x, total+x)) → 100; 250; 340

    Try this example

  2. The highest so far

    ABC
    1Score
    255
    335
    488
    568

    In C2: =SCAN(0, A2:A5, LAMBDA(best, x, MAX(best, x))) → 5; 5; 8; 8

    Try this example

Common mistakes

Try SCAN in the playground

Practise it

Related functions