
Filtering a list by a condition in Excel used to need advanced filter, helper columns or complicated array formulas. The dynamic arrays that came with Microsoft 365 and Excel 2021 changed this: you write a single formula, the result spills into neighbouring cells by itself and updates as the source data changes. In this guide you learn FILTER, SORT, UNIQUE and related functions with real examples.
What is a dynamic array and how does spilling work?
A normal formula returns one value in one cell. A dynamic array formula can return several values and spreads them across the spill range starting at the cell where the formula is written. You write the formula only in the first cell; Excel fills the others and shows them with a blue border.
To refer to the whole spilled range, put # at the end of the first cell's address: =D2#. If the source data grows or shrinks the range adapts automatically; you don't need to drag the formula.
Important: dynamic arrays are in Microsoft 365, Excel 2021 and later, and Excel for the web. Older versions (2016, 2019) don't have the functions.
FILTER: bringing back rows that meet a condition
=FILTER(array, include, [if_empty])
Say the sales table is in A2:C100, with region in column B and amount in column C. All the London rows:
=FILTER(A2:C100, B2:B100="London", "No records")
For several conditions use multiplication (AND) and addition (OR):
- AND:
=FILTER(A2:C100, (B2:B100="London")*(C2:C100>1000)) - OR:
=FILTER(A2:C100, (B2:B100="London")+(B2:B100="Paris"))
The third argument is the text shown if there is no match at all. If you leave it out you see a #CALC! error.
- 1
Identify the source table (A2:C100)
- 2
Write the condition (B2:B100="London")
- 3
Add a message for no match
- 4
Check the result in the spilled range
SORT and SORTBY
=SORT(array, [sort_index], [sort_order], [by_col])
For the order, 1 means ascending and -1 descending. To sort amounts from large to small:
=SORT(A2:C100, 3, -1)
When the criterion range lies outside the array use SORTBY: =SORTBY(A2:C100, C2:C100, -1). You can give several criteria: first region, then amount.
UNIQUE: a list without repeats
=UNIQUE(B2:B100) lists the different values in the region column. If you want values that occur only once set the third argument to TRUE: =UNIQUE(B2:B100, , TRUE).
To find how many different values there are: =COUNTA(UNIQUE(B2:B100)), which takes the length of the unique list. In our data cleaning guide we also covered ways to weed out duplicate records.
Combining functions: a sorted, unique list
Dynamic arrays nest. To list each region once in alphabetical order:
=SORT(UNIQUE(B2:B100))
To bring London's rows in descending order of amount:
=SORT(FILTER(A2:C100, B2:B100="London"), 3, -1)
Combinations like these remove the need for helper columns and make formulas more readable.
Working with a spilled range: the # operator
To use a spilled result in another formula, add # to the first cell of the range:
=SUM(F2#)the total of the spilled range=COUNTA(F2#)how many items came back- Using
=F2#as the list source in data validation lets you build a dynamic drop-down (see our drop-down guide)
Other useful dynamic array functions
| Function | What it does |
|---|---|
| SEQUENCE | Produces a series of numbers |
| CHOOSECOLS / CHOOSEROWS | Picks specific columns or rows of an array |
| HSTACK / VSTACK | Joins arrays horizontally or vertically |
| TOCOL / TOROW | Turns an array into one column or row |
| XLOOKUP | Modern lookup that can return arrays (see our XLOOKUP guide) |
Function names vary with the Excel language version; the English names are FILTER, SORT, SORTBY, UNIQUE, SEQUENCE, CHOOSECOLS, HSTACK, VSTACK, TOCOL and XLOOKUP.
Common errors and fixes
| Error | Cause | Fix |
|---|---|---|
| #SPILL! | A filled cell is in the spill path | Clear the cells in the way |
| #CALC! | No match in FILTER | Put "No records" in the third argument |
| #VALUE! | Array sizes don't match | The condition range and array need the same number of rows |
| #NAME? | An older version or a wrong name | Check the version and function name |
| No spill inside a table | Excel tables don't support spilling | Write the formula outside the table |
Practice: automating a sales report
- Turn your data into a table (Ctrl + T) and name it; use the table name in formulas.
- Open a new "Report" sheet.
- In A2 write
=SORT(UNIQUE(Sales[Region])); the regions line up. - In B2 write
=SUMIFS(Sales[Amount], Sales[Region], A2#)to get each region's total (see our SUMIFS guide). - When a new sale is added the report updates itself.
- If you want formulas rather than a PivotTable for the summary this structure is a good alternative (see our PivotTable guide).
Frequently asked questions
Are dynamic arrays compatible with old files? If the file is opened in older Excel, formulas may appear with an @ sign or as fixed values; think of the recipient's version before sharing.
Is it in Google Sheets? Yes: FILTER, SORT and UNIQUE work similarly and the result spills automatically (see our Sheets vs Excel guide).
Is FILTER case-sensitive? No, text comparison is case-insensitive.
Can I turn the spilled range into values? Yes: copy the range and paste with Paste Special > Values.
Does it slow down on very large data? Many nested array formulas can slow calculation; use Power Query if needed (see our Power Query guide).
Summary
Dynamic arrays make filtering, sorting and building unique lists possible with one formula. Learning the FILTER, SORT and UNIQUE trio both shortens and automates your reports. Keep the spill path clear, add an empty-result message to FILTER and refer to the spilled range with the # operator.
Serkan Akyürek is the founder and author of toolrota; he writes step-by-step guides on Excel, AI, the cloud, personal finance and digital security.