Google Sheets | SCAN | Function | Calculate Running Total | Example | Spreadsheet | Tutorial

Published: 18 July 2024
on channel: Software Spring
238
8

With the Google Sheets SCAN function, it is simple to calculate running total, running count, and the like. SCAN scans each row of a specified array and returns intermediate values.

The SCAN function uses three arguments, and one of these arguments is the LAMBDA function, which is looped the number of times the total number of values in the array.

-------------------------------------
How to Use QUERY in Google Sheets?

QUERY helps, among others, to extract specific or all data from a range:

   • Google Sheets | QUERY | Function | Ex...  
-------------------------------------
How to Use Convert to Table in Google Sheets?

Convert a data range into a table easily:

   • Google Sheets | Convert to Table | Ch...  
-------------------------------------
How to Use FREQUENCY in Google Sheets?

FREQUENCY returns the frequency distribution of data:

   • Google Sheets | FREQUENCY | Function ...  
-------------------------------------
How to Use COUNTIFS in Google Sheets?

Count values that fulfill one or more criteria:

   • How to use COUNTIFS in Google Sheets ...  
-------------------------------------
How to Use XLOOKUP to Extract Multiple Values in Google Sheets?

XLOOKUP can return a single row or column with the search key:

   • Google Sheets | XLOOKUP | Function | ...  
-------------------------------------
How to Use VLOOKUP in Google Sheets?

Use VLOOKUP to get a single value:

   • VLOOKUP Google Sheets | How to Use VL...  
-------------------------------------
How to Use IFS in Google Sheets?

IFS allow multiple logical expressions:

   • Google Sheets IFS | Test Multiple Con...  
-------------------------------------
How to Use IF in Google Sheets?

Use IF to compare one value with another:

   • Google Sheets IF | Tutorial | IF Goog...  
-------------------------------------
How to Create a Pivot Table in Google Sheets?

Create a pivot table for calculation and in-depth data analysis:

   • Google Sheets | Pivot Table | How to ...  
-------------------------------------

Syntax of the SCAN Function

=SCAN(initial_value, array_or_range, lambda)

initial_value is the value LAMBDA function applies to the first element of the array.

array_or_range is the data source to scan.

lambda is a custom function applied to each element of the array. The lambda should have two name arguments and a formula expression. It uses the two named arguments.

The first argument equals the initial_value during the first scan. During subsequent scans, the first argument equals the previous value returned by lambda. The second argument equals the current value of the array.

An Example of the SCAN Function

=SCAN(2, A2:A4, LAMBDA(current_value, array_value, current_value+array_value)

Assume that the values in each cell of the range A2 to A4 are 201, 301, and 401 respectively. The scan function returns these intermediate values:
203, 504, 905.

Take a look at this video tutorial, which gives the steps to use the Google Sheets SCAN function, with examples.