Sum, Count or Average FILTER Results in Excel
By ExcelReady TeamUpdated 6 min read
The short answer
To sum FILTER results in Excel, put FILTER inside SUM: =SUM(FILTER(D2:D9,B2:B9="East")) adds the sales of East rows only. Swap SUM for COUNT, AVERAGE or MAX for other answers. Add 0 as FILTER's third argument so no matches return 0 instead of #CALC!. To total rows left visible by the filter buttons, use =SUBTOTAL(109,D2:D9).
Key takeaways
- Filter only the column you want to add, then wrap it: =SUM(FILTER(sales,test)).
- Give FILTER an if_empty value of 0 so the sum shows 0 when nothing matches.
- Multiply tests for AND and add them for OR; this is where FILTER beats SUMIFS.
- To total a spilled FILTER result already on the sheet, use its spill reference, like =SUM(F2#).
- For rows hidden with the filter buttons, use SUBTOTAL(109,range), not SUM.
On this page+
To sum FILTER results in Excel, wrap the FILTER formula in SUM: FILTER picks the matching values and SUM adds them up. The same idea works with COUNT, AVERAGE, MAX and MIN. This guide shows each one on a small sales table, how to avoid errors when nothing matches, and how to total rows you filtered with the filter buttons instead.
How to sum FILTER results with one formula#
Filter the column you want to add, then put SUM around it. The pattern is:
=SUM(FILTER(column_to_add, test))FILTER needs Excel 2021, Excel 2024 or Microsoft 365. Inside SUM, the results don't spill: SUM receives the whole list and returns one number. The FILTER function guide and the SUM function guide cover each function on its own.
All the examples use this table in A1:D9:
| A | B | C | D | |
|---|---|---|---|---|
| 1 | Rep | Region | Product | Sales |
| 2 | Ana | East | Laptop | 1200 |
| 3 | Ben | West | Phone | 800 |
| 4 | Cara | East | Phone | 650 |
| 5 | Dev | South | Laptop | 1500 |
| 6 | Eli | East | Tablet | 900 |
| 7 | Femi | West | Laptop | 1100 |
| 8 | Gus | South | Phone | 700 |
| 9 | Hana | East | Laptop | 1300 |
To add the East sales:
=SUM(FILTER(D2:D9,B2:B9="East"))FILTER returns 1200, 650, 900 and 1300. SUM adds them: 4,050. Notice the first argument is only the Sales column, D2:D9. If you filter the whole table A2:D9, SUM still works, but it's harder to read and easy to get wrong.
Count, average, max and min of FILTER results#
Swap SUM for another function to answer a different question about the same rows:
| Question | Formula | Result |
|---|---|---|
| How many East sales? | =COUNT(FILTER(D2:D9,B2:B9="East")) | 4 |
| Average East sale | =AVERAGE(FILTER(D2:D9,B2:B9="East")) | 1012.5 |
| Biggest East sale | =MAX(FILTER(D2:D9,B2:B9="East")) | 1300 |
| Smallest East sale | =MIN(FILTER(D2:D9,B2:B9="East")) | 650 |
| Number of rows returned | =ROWS(FILTER(A2:D9,B2:B9="East")) | 4 |
COUNT counts numbers, so use it on a number column like Sales. ROWS counts the rows FILTER returns from any range. Both are reliable when at least one row matches. The next section explains what happens when none do.
What happens when nothing matches?#
When no row passes the test, FILTER returns a #CALC! error, and SUM passes that error on. Try =SUM(FILTER(D2:D9,B2:B9="North")): there is no North region, so the cell shows #CALC!.
Fix it with FILTER's third argument, if_empty. For a sum, use 0:
=SUM(FILTER(D2:D9,B2:B9="North",0))The result is 0. For counts, use an empty text "" with COUNT, which ignores text: =COUNT(FILTER(D2:D9,B2:B9="North","")) returns 0. Don't use ROWS or COUNTA here: they count the one cell holding the message or error and return 1. For an average, wrap the formula in IFERROR, because the average of nothing is a #DIV/0! error.
Sum with AND, OR and other tests#
FILTER's test can be any formula that returns TRUE or FALSE for each row, so it handles conditions that are hard with SUMIFS.
AND: multiply the tests. East laptops:
=SUM(FILTER(D2:D9,(B2:B9="East")*(C2:C9="Laptop")))That returns 1200 + 1300 = 2,500.
OR: add the tests. East or West:
=SUM(FILTER(D2:D9,(B2:B9="East")+(B2:B9="West")))That returns 4,050 + 800 + 1,100 = 5,950. With SUMIFS you'd need two SUMIFS added together.
Tests with functions: FILTER can use MONTH, YEAR, LEFT or SEARCH on the column. For example, ISNUMBER(SEARCH("lap",C2:C9)) matches any product containing "lap". The guides to FILTER with multiple criteria, FILTER by date and FILTER for text that contains a word show many more tests you can sum.
How to total a FILTER result already on the sheet#
If a FILTER formula already spills a table on the sheet, refer to its result with the spill range operator #. Say F2 holds =FILTER(D2:D9,B2:B9="East"). Then:
=SUM(F2#)returns 4,050, and it stays right when the filtered list grows or shrinks. If the spill has several columns, pick one with INDEX. With =FILTER(A2:D9,B2:B9="East") in F2, =SUM(INDEX(F2#,,4)) adds the fourth column, Sales.
Show the matching rows and their total together#
A filtered list changes length, so a total typed under it can end up in the way of the spill. Put the total above the list instead. With the region to show in F1:
- In F3, type
=FILTER(A2:D9,B2:B9=F1,"No sales")to list the matching rows. - In I1, type
=SUM(FILTER(D2:D9,B2:B9=F1,0))for their total.
Type East in F1, and the list shows four rows with 4,050 above it. Type West, and it shrinks to two rows with 1,900. Nothing ever sits below the spill, so you never get a #SPILL! error, and a reader sees the detail and the answer at once.
How to sum rows filtered with the filter buttons#
If you filtered the table with the filter buttons (Data > Filter, or Ctrl+Shift+L; Mac: ⌘⇧F), SUM still adds every row, hidden or not. Use SUBTOTAL instead:
=SUBTOTAL(109,D2:D9)The 109 means "SUM, ignoring hidden rows". Filter the Region column to East, and the formula shows 4,050. Clear the filter, and it shows the full total of 8,150. Use 103 to count visible non-empty cells and 101 for the average.
AGGREGATE does the same job with more options, such as ignoring errors: =AGGREGATE(9,5,D2:D9) sums visible rows. The SUM function article explains why a plain SUM sometimes gives a total you didn't expect.
SUM with FILTER or SUMIFS?#
For one or two simple conditions, =SUMIFS(D2:D9,B2:B9,"East") gives the same 4,050, works in every version and is shorter. Choose SUM with FILTER when you need OR logic, a test built with another function, or when you want to show the matching rows and their total side by side.
Practise it#
Totalling the rows that match a condition is one of the most common tasks in Excel tests. Practise FILTER in a live spreadsheet: you type the formula and it checks it instantly. Then practise SUM and AutoSum to get fast at totals. Start with the exercise on this page: one formula for East laptop sales.
Try it yourself
This is a live spreadsheet. Type the formula in the green cell and press Enter.
What are the total sales of laptops in the East? In G2, wrap FILTER in SUM: filter D2:D9 where the region in B2:B9 is East and the product in C2:C9 is Laptop.
| A | B | C | D | E | F | G | H | |
|---|---|---|---|---|---|---|---|---|
| 1 | Sales | |||||||
| 2 | East laptops | |||||||
| 3 | ||||||||
| 4 | ||||||||
| 5 | ||||||||
| 6 | ||||||||
| 7 | ||||||||
| 8 | ||||||||
| 9 | ||||||||
| 10 | ||||||||
| 11 | ||||||||
| 12 |
Tip: Inside FILTER: the Sales column, then (B2:B9="East")*(C2:C9="Laptop"). Wrap the whole thing in SUM.
Practise this in a lesson
Frequently asked questions
How do I sum filtered data in Excel?
If you used the filter buttons, use =SUBTOTAL(109,D2:D9), which adds only the visible rows. If you want a formula that filters by itself, use =SUM(FILTER(D2:D9,B2:B9="East")).
Can you use SUM with FILTER in Excel?
Yes. FILTER returns the matching values and SUM adds them, for example =SUM(FILTER(D2:D9,C2:C9="Laptop")). It works in Excel 2021, Excel 2024 and Microsoft 365.
How do I count the results of a FILTER formula?
Use =COUNT(FILTER(D2:D9,B2:B9="East","")) on a number column, or ROWS for the number of rows returned. Be careful: ROWS and COUNTA return 1 when FILTER finds nothing, because the message or error still fills one cell.
Why does SUM(FILTER()) return #CALC!?
No rows matched the test, so FILTER returned an empty-array error. Add 0 as the third argument: =SUM(FILTER(D2:D9,B2:B9="North",0)).
Should I use SUMIFS or SUM with FILTER?
Use SUMIFS for simple AND conditions on columns; it is shorter and works in every version. Use SUM with FILTER for OR logic, tests built with functions like MONTH or SEARCH, or when you also want to see the matching rows.