When constructing financial models, inventory tracking sheets, or automated timestamping systems in Google Sheets, you may encounter the dreaded #REF! error accompanied by the warning message: “Circular dependency detected. To resolve with iterative calculation, see File > Settings.” A circular dependency arises when a formula directly or indirectly refers to its own cell. While often an unintentional formula mistake, intentional circular calculations are essential for solving iterative mathematical models, convergent goal-seeking formulas, and self-locking timestamps.
What Causes a Circular Dependency in Google Sheets?
Google Sheets evaluates formulas sequentially. When cell A1 contains =A1 + 1, or when A1 refers to B1 while B1 refers back to A1, an infinite calculation loop is created:
- Direct Circular Reference: A formula inside a cell explicitly references that same cell (e.g.,
=IF(A2="", "", IF(B2="", NOW(), B2))located inside cellB2). - Indirect Circular Reference: A chain of dependencies loops back to the origin (e.g., cell
A1depends onB1, which depends onC1, which calculates based onA1). - Why Iterative Calculation Resolves It: By default, Google Sheets halts calculation immediately to prevent your browser from freezing in an endless evaluation loop. Enabling Iterative Calculation instructs Google Sheets to evaluate the circular formula repeatedly until a designated maximum number of cycles is reached or until the numerical difference between iterations falls below a specified convergence threshold.
Step 1: Check and Fix Unintentional Circular Errors
Before turning on iterative calculation, confirm whether the circular reference is an accidental formula typo:
- Hover your cursor over the cell displaying the red #REF! triangle.
- Read the error tooltip: “Circular dependency detected…”
- Review your formula parameters. If you intended to sum a column (such as summing
A1:A10) but entered=SUM(A1:A11)inside cellA11, the formula is trying to calculate its own sum. - Correct the range boundary (e.g., change the formula inside
A11to=SUM(A1:A10)) to immediately clear the error without needing iterative settings.
Step 2: Enable Iterative Calculation for Intentional Models
If your spreadsheet intentionally relies on self-referencing logic (such as calculating interest based on revolving credit balances, goal-seeking convergence, or static timestamps):
- Open your spreadsheet in Google Sheets on desktop.
- Click File in the top menu bar and select Settings (or Spreadsheet settings).
- In the settings dialogue box, click the Calculation tab.
- Locate the Iterative calculation section.
- Click the drop-down selector and switch it from Off to On.
- Two configuration parameters will appear:
- Max number of iterations: Defines the maximum number of times Google Sheets will recalculate the formula in a single evaluation cycle (default is
50; standard financial models typically use between100and1000). - Threshold: Defines the minimum change between successive iterations required to stop recalculating (default is
0.05; for higher precision, set this to0.001or0.0001).
- Max number of iterations: Defines the maximum number of times Google Sheets will recalculate the formula in a single evaluation cycle (default is
- Click Save settings in the bottom right corner.
The #REF! error will vanish instantly, and Google Sheets will compute the convergent value according to your iteration limits.
Example Application: Creating a Static Timestamp Without Apps Script
One of the most practical uses of intentional circular dependencies is creating permanent creation timestamps that do not update every time the sheet recalculates:
- With Iterative Calculation enabled, assume you type task names into Column A, and you want an automatic, unchangeable creation date in Column B.
- In cell
B2, enter the following formula:=IF(A2="", "", IF(B2="", NOW(), B2)) - Format cell
B2as Format > Number > Date time. - When you type an entry into
A2, the formula inspects cellB2. SinceB2is currently empty, it stamps the currentNOW()value. On future recalculations, becauseB2already contains data, the formula returnsB2itself, permanently freezing the original timestamp.
Mastering iterative calculation enables advanced computational modeling while ensuring accidental circular loops are swiftly diagnosed and resolved.