SCAN(initial_value, array_or_range, LAMBDA)One free generation or explanation per browser, shared across Excel and Google Sheets. Account usage limits apply afterward.
initial_value:
The starting value for the accumulation process, which can be a number, text, or any other data type that matches the expected output of the LAMBDA function.
array_or_range:
The array or range of cells that you want to process with the LAMBDA function. This is the data that will be evaluated and transformed based on the logic defined in the LAMBDA.
LAMBDA:
A custom function that defines how to process each element of the array_or_range. It takes parameters (usually the current accumulated value and the current element) and returns a new accumulated value based on the specified logic.
The SCAN function in Google Sheets is a powerful tool that allows users to apply a function cumulatively across a range or array, returning an array of intermediate results. This function is particularly useful for scenarios where you want to track the progression of calculations or transformations as you iterate through a dataset.
In simpler terms, SCAN enables you to see how a calculation evolves step by step as it processes each element in a range.
Imagine you are tracking the daily sales of a product over a week and want to calculate the cumulative sales for each day:
| Day | Sales |
|---|---|
| Monday | 100 |
| Tuesday | 150 |
| Wednesday | 200 |
| Thursday | 250 |
| Friday | 300 |
You want to calculate the cumulative sales for each day, showing how sales accumulate over the week.
To achieve this, you would use the SCAN function as follows:
=SCAN(0, B2:B6, LAMBDA(acc, curr, acc + curr))In this formula:
0 is the initial value (the starting point for accumulation).B2:B6 is the range containing the daily sales data.LAMBDA(acc, curr, acc + curr) is a custom function that takes the accumulated value (acc) and the current value (curr), adding them together to produce the new accumulated value.When you apply the SCAN formula to the Daily Sales Table, the output would look like this:
| Day | Sales | Cumulative Sales |
|---|---|---|
| Monday | 100 | 100 |
| Tuesday | 150 | 250 |
| Wednesday | 200 | 450 |
| Thursday | 250 | 700 |
| Friday | 300 | 1000 |
As you can see, the Cumulative Sales column shows how the total sales accumulate day by day.
SCAN is beneficial because it allows for a clear visualization of how values accumulate over time or through a dataset. It simplifies the process of tracking cumulative totals without the need for complex formulas or additional columns. This makes your spreadsheets more efficient and easier to understand.
SCAN is an essential function for anyone working with data in Google Sheets, providing a powerful way to enhance data analysis and reporting capabilities.
Happy spreadsheeting!
You have a sales data table with monthly revenue in Column B. Use the SCAN formula to calculate cumulative revenue over the months in Column C. This allows you to easily track growth trends and make informed decisions based on total sales performance.
Sign up for Better Analyst and get unlimited AI-powered formula generation, explanations, and advanced data analysis.
Browse our complete library of Google Sheets formula guides
Compare your options
Open a neutral research prompt in the AI tool you already use. Compare capabilities, limitations, and fit before you choose.
AI answers can be incomplete. Check source links, current pricing, and product documentation before deciding.