toolrota

Excel dynamic arrays: building lists with one formula using FILTER, SORT and UNIQUE

Dynamic arrays fill hundreds of cells with one formula. We explain FILTER, SORT and UNIQUE with real tables, the spill operator and error fixes.

Serkan Akyürek··5 min read
Excel dynamic arrays: building lists with one formula using FILTER, SORT and UNIQUE – Excel

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.

Steps to build a FILTER formula
  1. 1

    Identify the source table (A2:C100)

  2. 2

    Write the condition (B2:B100="London")

  3. 3

    Add a message for no match

  4. 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

FunctionWhat it does
SEQUENCEProduces a series of numbers
CHOOSECOLS / CHOOSEROWSPicks specific columns or rows of an array
HSTACK / VSTACKJoins arrays horizontally or vertically
TOCOL / TOROWTurns an array into one column or row
XLOOKUPModern 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

ErrorCauseFix
#SPILL!A filled cell is in the spill pathClear the cells in the way
#CALC!No match in FILTERPut "No records" in the third argument
#VALUE!Array sizes don't matchThe condition range and array need the same number of rows
#NAME?An older version or a wrong nameCheck the version and function name
No spill inside a tableExcel tables don't support spillingWrite the formula outside the table

Practice: automating a sales report

  1. Turn your data into a table (Ctrl + T) and name it; use the table name in formulas.
  2. Open a new "Report" sheet.
  3. In A2 write =SORT(UNIQUE(Sales[Region])); the regions line up.
  4. In B2 write =SUMIFS(Sales[Amount], Sales[Region], A2#) to get each region's total (see our SUMIFS guide).
  5. When a new sale is added the report updates itself.
  6. 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.

Share
Published:
Author
Serkan Akyürek

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.

Related guides

Excel
Excel6 min read

Excel SUMPRODUCT function: conditional sums, weighted averages and practical examples

SUMPRODUCT multiplies, sums and counts with conditions in one formula. We explain it with sales tables, weighted grades and multi-criteria calculations.

Excel5 min read

How to create a drop-down list in Excel: simple, dynamic and dependent lists

If five spellings of the same department are breaking your reports, a drop-down list is the fix. From a basic list to self-expanding and dependent lists, step by step.

Excel4 min read

Get live exchange rates in Excel: Currencies data type, ECB rates and Google Sheets

Still typing exchange rates into your price list every morning? Excel can fetch them for you, including official central bank reference rates that refresh with one click.

Excel4 min read

Excel IF, AND and OR formulas: the complete guide to conditional logic

Showing a different result depending on a cell's value is one of Excel's most basic and most powerful skills. Combine IF with AND, OR and IFS to handle complex rules in one formula.

Excel4 min read

Excel rounding functions: ROUND, ROUNDUP, ROUNDDOWN and CEILING explained

Cell formatting rounds only the display, not the value. How to pick the right rounding function to avoid discrepancies in calculations.

AI7 min read

Running AI on your own computer: a step-by-step guide to local models with Ollama and LM Studio

Local AI runs without your data leaving your computer and needs no internet. We explain hardware needs, setup, model choice and limits.