How to Avoid Circular References in Dynamic Array Formulas with SCAN
Question details
The user wants to convert row-by-row formulas into a fully dynamic array without triggering circular reference errors or relying on slow iterative calculations.

- Product
- Spreadsheet
- Device & OS
- not provided
- Scenario
- Converting traditional row-by-row formulas into dynamic arrays that require carrying a state from one row to the next.
- Observed behavior
- Traditional methods cause circular references or require enabling slow iterative calculations, whereas the goal is to use the SCAN function for efficient sequential processing.
Ensure your spreadsheet software supports dynamic array functions like SCAN and LAMBDA. It is also recommended to turn off 'Enable iterative calculation' in your formula settings to properly test the new dynamic array approach.
Use the SCAN Function to Process Values Sequentially
Replace iterative calculations by using the SCAN function, which applies a LAMBDA to each value in an array while carrying the state forward.
The SCAN function is designed to iterate over an array, applying a custom LAMBDA function to each element. It maintains an accumulator (state) that updates with each step, making it perfect for replacing row-by-row formulas that depend on the previous row's result without causing circular references.
Determine the array or range you want to process, such as Table1[Col1].
Set the starting value for your accumulator in the first argument of the SCAN function (e.g., 0 or "").
Create a LAMBDA function with two parameters: one for the accumulator and one for the current value (e.g., LAMBDA(acc, val, acc + val)).
Assemble the formula like =SCAN(0, Table1[Col1], LAMBDA(acc, val, acc + val)) and test it on a small sample range before applying it to the entire dataset.

Master Dynamic Arrays with WPS Spreadsheet
WPS Office provides robust support for advanced spreadsheet functions, including dynamic arrays, allowing you to build complex, error-free data models without circular references.
- 1. Open WPS Spreadsheet: Launch WPS Office and open your workbook containing the data.
- 2. Enter your dynamic formula: Select the target cell and input your SCAN and LAMBDA formula.
- 3. Let the array spill: Press Enter, and WPS Spreadsheet will automatically spill the results into the adjacent cells without circular reference errors.

Frequently Asked Questions
What is a circular reference in a spreadsheet?
A circular reference occurs when a formula directly or indirectly refers to its own cell, causing an endless calculation loop. This often happens when trying to calculate running totals or states without using dynamic array functions like SCAN.
Why is the SCAN function better than enabling iterative calculation?
Enabling iterative calculation can slow down your workbook and mask accidental circular reference errors. The SCAN function processes data sequentially and carries a state forward natively, providing a faster, safer, and fully dynamic solution.
Can I use SCAN if my calculation needs data from two rows back?
Yes, but you will need to store multiple states in the accumulator. You can achieve this by passing an array of values using a CHOOSE-based LAMBDA or HSTACK within the SCAN function to keep track of multiple previous results.
Why is my SCAN formula returning a #CALC! error?
A #CALC! error in dynamic arrays usually means the formula is trying to produce an empty array or there is a syntax issue within the nested LAMBDA function. Double-check your LAMBDA parameters and ensure the source array is valid.




