<< Go back to all functions

SCAN

The SCAN function in Google Sheets is used to scan an array and produce intermediate values by applying a LAMBDA function to each value. It returns an array of the intermediate values obtained at each step.

Function Syntax and Parameters

Syntax: SCAN(initial_value, array_or_range, LAMBDA)

Parameters:

  • initial_value: The initial value for the scan.
  • array_or_range: The array or range to scan.
  • LAMBDA: The function to apply to each value in the array.

Step-by-Step Tutorial

  1. Using SCAN with a simple lambda function:

    • Example: =SCAN(0, {1,2,3,4,5}, LAMBDA(a, b, a + b))
    • Result: {0, 1, 3, 6, 10, 15}
  2. Using SCAN with more complex lambda functions:

    • Example: =SCAN("", {"apple", "banana", "carrot"}, LAMBDA(a, b, a & ", " & b))
    • Result: {", apple", ", apple, banana", ", apple, banana, carrot"}

Use Cases and Scenarios

  1. Running Total: Calculate the running total of a series of values.
  2. Concatenation: Concatenate values in a range with separators.
  3. Accumulating Values: Accumulate values with a specific operation.

Related Functions

None.

Related Articles

None.