How to Fix Circular Reference Errors When Sorting Filtered Excel Data
Question details
The user encounters a circular reference error when attempting to sort filtered data using dynamic array functions like SORTBY and FILTER, specifically when the sorting array relies on external calculations like XLOOKUP.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Writing complex dynamic array formulas that combine SORTBY, FILTER, and XLOOKUP to dynamically filter and sort a dataset based on lookup values.
- Observed behavior
- Excel returns a circular-reference warning because the formula column used for sorting directly depends on the output range being filtered, creating an infinite calculation loop.
Check the status bar at the bottom of your spreadsheet window, which displays 'Circular References' followed by a cell address, to identify exactly which cell is triggering the loop.
Separate Calculations Using a Helper Column
Isolate the XLOOKUP calculation from your dynamic array formula by placing it in its own helper column within the source data, breaking the circular dependency.
By calculating your lookup values independently of the final array formula, the sorting function no longer relies on the output range, safely preventing calculation loops.
Insert a new column directly into your original source data table to hold the lookup values.
Type your XLOOKUP formula in the first cell of the helper column and drag it down to calculate the corresponding values (e.g., dates) for your entire source dataset independently.
In your destination cell, write your standard FILTER formula to extract the necessary rows from the source data.
Wrap the FILTER formula in a SORTBY function, setting the newly created helper column range as the 'by_array' argument. This ensures the sorted output references independent data.

Use the LET Function for Self-Contained Arrays
Utilize the LET function to define standalone variables for your lookup values and source data within a single formula, eliminating the dependency loop without needing extra columns.
Solve Complex Formula Errors Easily with WPS Office
WPS Spreadsheet fully supports modern dynamic array functions like SORTBY, FILTER, XLOOKUP, and LET, making it simple to process large datasets. It also includes intuitive auditing tools to instantly trace and resolve circular references.
- 1. Open Formula Auditing Tools: Open your workbook in WPS Spreadsheet, navigate to the 'Formulas' tab, and click 'Error Checking' to automatically locate the exact cell causing the circular reference.
- 2. Trace Formula Precedents: Click on 'Trace Precedents' or 'Trace Dependents' to display visual arrows on your sheet, helping you map out the dependency loop.
- 3. Rewrite with Dynamic Arrays: Use WPS Spreadsheet's native support for the LET function to rewrite the formula, effectively decoupling the variables and fixing the circular dependency.

Frequently Asked Questions
Why do SORTBY and FILTER cause a circular reference?
A circular reference occurs when a formula refers to its own cell or depends on its own output to calculate a result. When sorting filtered data, if the column you are sorting by is dynamically generated by referencing the output of the filter itself, Excel enters a continuous dependency loop.
How do I find all circular references in my workbook?
Navigate to the Formulas tab on the ribbon, click the drop-down arrow next to 'Error Checking', and hover over 'Circular References'. This will display a list of all specific cell addresses currently involved in a calculation loop.
Are XLOOKUP, SORTBY, and FILTER available in older versions of Excel?
No, these dynamic array functions are only natively available in Microsoft 365 and Excel 2021 or later. If you are using an older version, you must use alternative methods like INDEX/MATCH combinations or switch to a compatible modern suite like WPS Office.




