Microsoft 365

Excel FILTER Function With Multiple Criteria, Sorted With SORT and SORTBY

Filter Excel data on several conditions with FILTER, keep only the columns you need, and sort the result with SORT and SORTBY, with fixes for #CALC!, #SPILL! and #VALUE!.

By EpiFive Editorial TeamReviewed/updated 15 min readHow we check articles
On this page

To filter Excel data on more than one condition, wrap each condition in brackets inside FILTER and join them with * for AND or + for OR, for example =FILTER(A2:F13,(C2:C13="East")*(F2:F13>=1500),"No matches"). Wrap that formula in SORT to order the result by one column, or in SORTBY to sort by several columns, and the whole report updates by itself when the data changes.

This guide builds one small sales report step by step, and every formula comes with the exact result it returns on the sample data, so you can check your own sheet as you go.

Who this is for and what you will have at the end

This is for anyone who keeps a list in Excel, such as orders, invoices or tickets, and keeps reapplying AutoFilter every time someone asks for "East region, over 1,500, biggest first". FILTER does the same job with a formula, so the answer stays live.

By the end you will have FILTER formulas for AND, OR, "contains" text and date ranges, a result with only the columns you choose, sorting by one or more columns, a top 3 list, a report driven by input cells, and fixes for the errors these formulas produce.

Before you start: Excel versions and the sample data

These are dynamic array functions. A dynamic array formula is typed in one cell and its results "spill" into the cells next to it. Check that your Excel version has the functions you plan to use. The table below follows the Applies to lists on Microsoft's function pages.

FunctionListed by Microsoft for
FILTER, SORT, SORTBY, LETExcel for Microsoft 365 (Windows and Mac), Excel 2024, Excel 2021, Excel for iPad, iPhone and Android
CHOOSECOLS, TAKEExcel for Microsoft 365 (Windows and Mac), Excel 2024

If you share the workbook with people on an older version, see the #NAME? fix in the errors section.

The sample sales table

Type or paste this table into a new sheet so that the header Order is in cell A1 and the last row ends in F13. The data is fictional Contoso-style sales.

OrderDateRegionProductUnitsRevenue
10012026-01-05EastLaptop Pro 1433600
10022026-01-09WestWireless Mouse25625
10032026-01-14EastUSB-C Dock81440
10042026-01-22NorthLaptop Air 1354500
10052026-02-03WestLaptop Pro 1444800
10062026-02-11SouthMonitor 2761920
10072026-02-17EastWireless Mouse401000
10082026-02-25NorthUSB-C Dock101800
10092026-03-04EastLaptop Air 1321800
10102026-03-12SouthLaptop Pro 1467200
10112026-03-19WestMonitor 273960
10122026-03-27EastMonitor 2792880

So the data rows are A2:F13: column A is Order, B is Date, C is Region, D is Product, E is Units and F is Revenue. Make sure the dates are real Excel dates, not text.

Unless a section says otherwise, type each formula into cell H4 and replace it as you work through the examples. H4 has empty space to the right and below, which the results need.

FILTER syntax and a first formula

Microsoft documents the syntax as:

=FILTER(array,include,[if_empty])
  • array is the range to filter, here A2:F13.
  • include is a Boolean (TRUE/FALSE) array whose height or width matches the array. In practice it is a test on one column, such as C2:C13="East".
  • if_empty is optional: the value to return when nothing matches.

To list every East order:

=FILTER(A2:F13,C2:C13="East","No matches")

Result: five rows spill into H4:M8, orders 1001, 1003, 1007, 1009 and 1012, with all six columns. Only H4 contains the formula. If you select another cell in the result, the formula appears ghosted (grayed out) in the formula bar, and Microsoft notes that only the first cell of the spill area can be edited.

If the Date column of the result shows five-digit numbers such as 46027, those are Excel date serial numbers. Select that column of the result and apply Short Date from the Number group on the Home tab.

Why if_empty matters

Try a region that does not exist:

=FILTER(A2:F13,C2:C13="Central","No matches")

Result: a single cell that says No matches. Remove the third argument and the same formula returns #CALC!, because, in Microsoft's words, Excel does not currently support empty arrays. Use "" as if_empty if you would rather show a blank cell.

FILTER with multiple criteria

Each condition produces a column of TRUE and FALSE values, one per row. Multiplying or adding two of those columns gives a number for each row, with TRUE counting as 1 and FALSE as 0, and FILTER keeps the rows where that number is not 0.

AND: multiply the conditions with *

A row is kept only when every condition is TRUE, because 1 times 1 is 1 and anything times 0 is 0. East orders with revenue of at least 1,500:

=FILTER(A2:F13,(C2:C13="East")*(F2:F13>=1500),"No matches")

Result: three rows, orders 1001 (3600), 1009 (1800) and 1012 (2880). Orders 1003 and 1007 are East but below 1,500, so they drop out.

Put brackets around each condition. Microsoft's operator precedence table ranks multiplication and addition above comparison operators such as = and >=, so without brackets Excel multiplies before it compares and the logic breaks.

OR: add the conditions with +

A row is kept when at least one condition is TRUE, because the sum is then 1 or more. North or South orders:

=FILTER(A2:F13,(C2:C13="North")+(C2:C13="South"),"No matches")

Result: four rows, orders 1004, 1006, 1008 and 1010.

Combine AND and OR

Put the OR part in its own set of brackets, then multiply by the AND part. North or South orders with revenue over 2,000:

=FILTER(A2:F13,((C2:C13="North")+(C2:C13="South"))*(F2:F13>2000),"No matches")

Result: two rows, orders 1004 (4500) and 1010 (7200). Orders 1006 (1920) and 1008 (1800) are in the right regions but not over 2,000.

An equals sign only matches the whole cell. To keep rows where the product name contains a word, use SEARCH, which returns the position of the text or #VALUE! when it is not found. ISNUMBER turns that into TRUE or FALSE:

=FILTER(A2:F13,ISNUMBER(SEARCH("laptop",D2:D13)),"No matches")

Result: five rows, orders 1001, 1004, 1005, 1009 and 1010, every Laptop Pro 14 and Laptop Air 13. SEARCH is not case-sensitive, so "laptop" matches "Laptop". Use FIND in place of SEARCH when case matters.

Date range

Compare the Date column with two dates built by DATE(year,month,day) and multiply the tests. All February 2026 orders:

=FILTER(A2:F13,(B2:B13>=DATE(2026,2,1))*(B2:B13<=DATE(2026,2,28)),"No matches")

Result: four rows, orders 1005, 1006, 1007 and 1008. DATE builds each date from year, month and day numbers, so there is no doubt about which day the formula means.

Return only the columns you need with CHOOSECOLS

A report often needs just a few columns. CHOOSECOLS returns the columns you list by number:

=CHOOSECOLS(array,col_num1,[col_num2],...)

Pick the columns first, then filter. Order, Product and Revenue for East:

=FILTER(CHOOSECOLS(A2:F13,1,4,6),C2:C13="East","No matches")

Result: five rows and three columns: 1001 Laptop Pro 14 3600, 1003 USB-C Dock 1440, 1007 Wireless Mouse 1000, 1009 Laptop Air 13 1800, and 1012 Monitor 27 2880.

The order matters. If you write =CHOOSECOLS(FILTER(...),1,4,6) and nothing matches, FILTER returns the single cell "No matches", and CHOOSECOLS then returns #VALUE! because, as Microsoft's page explains, a column number larger than the number of columns is an error. Filtering last avoids that.

CHOOSECOLS is listed for Microsoft 365 and Excel 2024. In Excel 2021 you can get the same three columns by filtering a second time across the columns with a row of 1s and 0s, where 1 keeps a column:

=FILTER(FILTER(A2:F13,C2:C13="East","No matches"),{1,0,0,1,0,1})

Result: the same five rows and three columns as above.

Sort the results with SORT

SORT orders a range or array by one of its columns:

=SORT(array,[sort_index],[sort_order],[by_col])
  • sort_index is the column number inside the array to sort by. If you leave it out, the first column is used.
  • sort_order is 1 for ascending (the default) or -1 for descending.
  • by_col is FALSE (the default) to sort rows, or TRUE to sort columns.

East orders, largest revenue first. Revenue is the sixth column of A2:F13:

=SORT(FILTER(A2:F13,C2:C13="East","No matches"),6,-1)

Result: orders 1001 (3600), 1012 (2880), 1009 (1800), 1003 (1440) and 1007 (1000), in that order.

The sort_index counts columns in the array SORT receives, not sheet columns. If you sort the three-column CHOOSECOLS result, Revenue is column 3, not 6.

Sort by multiple columns with SORTBY

SORTBY sorts one array by other ranges and accepts several sort keys:

=SORTBY(array,by_array1,[sort_order1],[by_array2,sort_order2],...)

Each by_array must be a single column (or a single row), and Microsoft states that all arguments must be the same size. A sort order other than 1 or -1 returns #VALUE!. Microsoft's SORT page also recommends SORTBY for sorting data in the grid, because it refers to a range rather than a column number and keeps working when columns are added or removed.

The whole table by Region A to Z, then by Revenue largest first within each region:

=SORTBY(A2:F13,C2:C13,1,F2:F13,-1)

Result: East 1001, 1012, 1009, 1003, 1007; North 1004, 1008; South 1010, 1006; West 1005, 1011, 1002.

SORTBY on a filtered result

Every by_array must match the size of the array, so C2:C13 will not work against a filtered result with fewer rows. Filter the sort columns with the same condition instead. Orders with revenue of at least 1,500, by Region, then by Revenue descending:

=SORTBY(FILTER(A2:F13,F2:F13>=1500,"No matches"),FILTER(C2:C13,F2:F13>=1500),1,FILTER(F2:F13,F2:F13>=1500),-1)

A shorter version names the filtered result once with LET and picks the sort columns out of it with CHOOSECOLS (Microsoft 365 and Excel 2024):

=LET(data,FILTER(A2:F13,F2:F13>=1500,"No matches"),SORTBY(data,CHOOSECOLS(data,3),1,CHOOSECOLS(data,6),-1))

Result for both: eight rows, East 1001 (3600), 1012 (2880), 1009 (1800); North 1004 (4500), 1008 (1800); South 1010 (7200), 1006 (1920); West 1005 (4800).

Show the top N with TAKE

TAKE returns a number of rows or columns from the start or end of an array:

=TAKE(array,rows,[columns])

A negative number takes from the end. Sort descending, then take the first rows. Top 3 orders by revenue:

=TAKE(SORT(A2:F13,6,-1),3)

Result: 1010 (7200), 1005 (4800) and 1004 (4500).

Top 3 East orders:

=TAKE(SORT(FILTER(A2:F13,C2:C13="East","No matches"),6,-1),3)

Result: 1001 (3600), 1012 (2880) and 1009 (1800). TAKE is listed for Microsoft 365 and Excel 2024.

Build a live report from criteria cells

A report is easier to reuse when the criteria sit in cells. Set up:

  • H1: Region, and I1: East
  • H2: Min revenue, and I2: 1500

Then in H4:

=SORT(FILTER(A2:F13,(C2:C13=I1)*(F2:F13>=I2),"No matches"),6,-1)

Result: 1001 (3600), 1012 (2880) and 1009 (1800). Type West in I1 and the result changes at once to 1005 (4800) alone.

To let a blank region cell mean "all regions", add an OR test on the input cell itself:

=FILTER(A2:F13,((C2:C13=I1)+(I1=""))*(F2:F13>=I2),"No matches")

With I1 cleared and I2 still 1500, the result is the eight orders of 1,500 or more: 1001, 1004, 1005, 1006, 1008, 1009, 1010 and 1012.

Keep the criteria cells outside the area the result will fill. If an input cell sits inside the spill range, the formula shows #SPILL! instead of results.

Refer to the spilled results with

To use the whole spilled result in another formula, add the spilled range operator # after the address of the formula cell. With =FILTER(A2:F13,C2:C13="East","No matches") in H4, enter these in empty cells outside H4:M8, such as O1 and O2:

=ROWS(H4#)
=SUM(TAKE(H4#,,-1))

Results: 5 matching orders, and 10720 total East revenue (TAKE with -1 columns returns the last column, Revenue). When the filter returns more or fewer rows, both formulas follow automatically. If FILTER shows "No matches", ROWS returns 1, so test for that text before you report a count.

Microsoft notes that the spilled range operator does not support references to closed workbooks; those return #REF! until you open the source workbook.

Use an Excel table so new rows are included

A fixed range like A2:F13 does not grow when you add row 14. Convert the data to an Excel table: select a cell in the data, choose Home > Format as Table, pick a style, and confirm the header row. Then select a cell in the table and type Sales in the Table Name box on the Table Design tab.

The table name on its own refers to the data rows without the header, and Sales[Region] refers to one column:

=FILTER(Sales,(Sales[Region]="East")*(Sales[Revenue]>=1500),"No matches")

Result: orders 1001, 1009 and 1012, as before. Add an East order with revenue of 2,400 directly under the table and it becomes part of the table, so it appears in the result without editing the formula.

FILTER does not return the header row. To label the output, put this in the cell above the formula, for example in H3:

=Sales[#Headers]

Place these formulas on the grid outside the table. Microsoft states that spilled array formulas are not supported inside Excel tables.

Common errors and fixes

ErrorCauseFix
#CALC!No rows match and if_empty is missingAdd a third argument such as "No matches" or ""
#SPILL!Cells in the spill range are not emptySelect the formula, choose Select Obstructing Cells, clear or move that content
#SPILL!Formula is inside an Excel tableMove it outside the table, or convert the table to a range
#SPILL!Spill range contains merged cellsUnmerge them or move the formula
#VALUE!include range is a different size from arrayMake both ranges start and end on the same rows
#VALUE!SORTBY sort order is not 1 or -1Use 1 for ascending or -1 for descending
#VALUE!CHOOSECOLS column number is 0 or too largeCount columns in the array it receives
#NAME?Text criterion without quotes, or function not availableAdd quotes; check your Excel version
#REF!Source or spilled range is in a closed workbookOpen the source workbook

#SPILL!

When you select the formula cell, a dashed border shows where the results want to go, and the error alert offers Select Obstructing Cells to jump to the blocker. Microsoft also lists results that would run past the edge of the worksheet and running out of memory; reference a smaller range for both. To keep a formula that sits in a table, convert the table with Table Design > Tools > Convert to range.

#VALUE! with mismatched ranges

=FILTER(A2:F13,C2:C12="East","No matches") tests 11 rows against 12 data rows and returns #VALUE! in current Excel. An Excel table avoids this, because Sales and Sales[Region] always cover the same rows.

#NAME?

Microsoft's #NAME? page gives a misspelled function name as the top reason, and text without double quotation marks as another: C2:C13=East returns #NAME?, while C2:C13="East" works. A function missing from your version, such as CHOOSECOLS in Excel 2021, is not recognized either. For workbooks shared with older versions, Microsoft advises avoiding features those users lack and running the Compatibility Checker to find dynamic array formulas, which older versions show as legacy array formulas that cannot resize.

Checklist

  • Each FILTER has a third argument so an empty result shows text instead of #CALC!.
  • Every condition is in its own brackets; * joins AND conditions and + joins OR conditions.
  • The include ranges start and end on the same rows as the array.
  • SORT uses the column number inside the array it sorts; SORTBY uses ranges of the same size with 1 or -1.
  • CHOOSECOLS runs before FILTER, not after, so an empty result does not turn into #VALUE!.
  • Criteria cells and other content sit outside the spill range.
  • The source data is an Excel table, and the formulas sit outside it.
  • Everyone who opens the file has a version that lists the functions used.

For more on dynamic array functions, see remove duplicates and count unique values in Excel, and for tidying a messy list before you filter it, see clean messy spreadsheet data with AI in Excel and Google Sheets. More Microsoft 365 tutorials cover Excel, Outlook and the rest of the suite.

References

Questions people ask

How do I use the FILTER function with multiple criteria in Excel?

Put each condition in brackets and multiply them for AND, for example =FILTER(A2:F13,(C2:C13="East")*(F2:F13>=1500),"No matches"). Add them with + for OR, for example (C2:C13="North")+(C2:C13="South"). Microsoft's FILTER page uses exactly these two patterns.

How do I sort by multiple columns in Excel with a formula?

Use SORTBY and give it one sort column and sort order per key, for example =SORTBY(A2:F13,C2:C13,1,F2:F13,-1) sorts by region A to Z and then by revenue from largest to smallest. A sort order of 1 is ascending, -1 is descending, and any other value returns #VALUE!.

Why does my FILTER formula return

FILTER returns #CALC! when no rows match and you left out the third argument, because Excel cannot return an empty array. Add if_empty, for example "No matches" or "", so the formula shows that value instead of an error.

What does the

The formula returns several values but Excel cannot place them on the grid. The most common cause is a cell in the spill range that is not empty; select the formula cell, use Select Obstructing Cells, and clear or move that content. Spilled formulas also cannot sit inside an Excel table or spill into merged cells.

ExcelFILTER functionSORT functionDynamic arraysMicrosoft 365
  1. Office Scripts: Automate a Weekly Excel Report With Power Automate

    Write an Office Script that totals last week's sales by region, writes a formatted summary sheet and returns the figures to a scheduled Power Automate flow that emails them.

    Microsoft 36519 min read
  2. Split and Combine Text in Excel With TEXTSPLIT and TEXTJOIN (Examples)

    Split cells into columns or rows with TEXTSPLIT, pull out names and email domains with TEXTBEFORE and TEXTAFTER, and join lists with TEXTJOIN, with fixes for common errors.

    Microsoft 36513 min read
  3. XLOOKUP vs VLOOKUP in Excel: Differences and Formulas With Examples

    Compare XLOOKUP and VLOOKUP on one sample table, with copy-paste formulas for exact, left, approximate, wildcard and two-criteria lookups, plus fixes for common errors.

    Microsoft 36515 min read
  4. Outlook Notifications Not Showing on Windows 11: Fix Alerts and Sound

    Get new-mail pop-ups and sounds back in new Outlook and classic Outlook on Windows 11 by checking Outlook, Windows notification, Focus, Do Not Disturb and Battery Saver settings in order.

    Microsoft 36510 min read
  5. Outlook Email Stuck in the Outbox: Fixes That Get Mail Sending Again

    Get queued messages out of the Outlook Outbox on Windows by checking Work Offline, removing large attachments, fixing Send immediately, and testing add-ins in safe mode.

    Microsoft 36510 min read
  6. Outlook Rules: Automatically Move or Forward Emails (Step by Step)

    Create Outlook rules that move mail from a sender to a folder or forward it automatically, in new Outlook, Outlook on the web, classic Outlook and Outlook for Mac, and fix rules that stop working.

    Microsoft 36513 min read