The best formula to use when you need to sum, count, or average data based on multiple criteria in Excel is the IFS family of functions: SUMIFS, COUNTIFS, and AVERAGEIFS. For example, =SUMIFS(C2:C100, A2:A100, "North", B2:B100, "Q1") adds all values in C2:C100 where column A equals “North” and column B equals “Q1”.
Why the IFS Family Replaced SUMPRODUCT
Before Excel 2007, the only way to apply multiple conditions was to use SUMPRODUCT with array-like syntax, such as =SUMPRODUCT((A2:A100="North")*(B2:B100="Q1")*C2:C100). That worked but was hard to read and slow on large datasets. The IFS functions (SUMIFS, COUNTIFS, AVERAGEIFS, MAXIFS, MINIFS) were introduced in Excel 2007 and are now the standard, faster, and more intuitive choice. They also handle blank cells and text more gracefully.
How SUMIFS, COUNTIFS, and AVERAGEIFS Work
All three functions share the same basic structure: you first specify the range to aggregate (for SUMIFS and AVERAGEIFS), then you add pairs of criteria ranges and criteria. For COUNTIFS, you skip the aggregate range and just list the criteria pairs.
- SUMIFS:
=SUMIFS(sum_range, criteria_range1, criteria1, [criteria_range2, criteria2], ...) - COUNTIFS:
=COUNTIFS(criteria_range1, criteria1, [criteria_range2, criteria2], ...) - AVERAGEIFS:
=AVERAGEIFS(average_range, criteria_range1, criteria1, ...)
Example: With sales in B2:B20, region in A2:A20, and product in C2:C20, to sum sales for “East” region and “Widget” product: =SUMIFS(B2:B20, A2:A20, "East", C2:C20, "Widget"). If you want to count how many rows meet those same conditions: =COUNTIFS(A2:A20, "East", C2:C20, "Widget").
Using Wildcards and Logical Operators
Criteria can include wildcards and comparison operators. Use an asterisk (*) for any sequence of characters, a question mark (?) for a single character, and a tilde (~) before a literal asterisk or question mark. For numeric comparisons, enclose the operator in quotes: ">10", "<=","&B1 (concatenate a cell reference). For example, to sum sales over 1000 in the East region: =SUMIFS(B2:B20, A2:A20, "East", B2:B20, ">1000"). Note that the sum range appears also as a criteria range in this case.
Handling Dates and Blank Cells
Dates are stored as numbers in Excel, so you can use operators with date criteria, but you must use the DATE function or a cell reference to avoid text-date mismatches. For example, to sum sales after January 1, 2025: =SUMIFS(B2:B20, A2:A20, "East", C2:C20, ">"&DATE(2025,1,1)). For blank cells, use "=" to match blanks (e.g., "=" as criteria) and "<>" for non-blanks. Be careful: using "" (empty string) may not match truly blank cells.
How to Choose Between SUMIFS, SUMPRODUCT, and FILTER
For most users, SUMIFS/COUNTIFS/AVERAGEIFS are the best choice because they are straightforward and fast. If you need to return a list of matching values (not just an aggregate), use the FILTER function (available in Excel 2021 and Microsoft 365). For complex logic like OR conditions (e.g., "North" OR "South"), you can either use multiple IFS functions added together or use SUMPRODUCT with + for OR logic. Example: =SUM(SUMIFS(B2:B20, A2:A20, {"North","South"})) works because the array constant makes SUMIFS return an array, which SUM adds up.
Common Mistakes and How to Fix Them
- Wrong range sizes: All criteria ranges and the sum range must be the same size and shape. If they aren't, you'll get a #VALUE! error.
- Mismatched data types: If you compare a number to a text-formatted number, it won't match. Ensure numeric cells are truly numbers.
- Using "equals" with text: Text criteria are case-insensitive but must match exactly (including spaces). Use wildcards if you need partial matches.
- Forgetting quotes around operators:
">100"is correct, not>100.
Frequently Asked Questions
Can I use OR logic in SUMIFS? Not directly. SUMIFS only supports AND logic (all criteria must be true). For OR, use an array constant as shown above, or use SUMPRODUCT.
How do I count unique values with multiple criteria? Use SUMPRODUCT with COUNTIFS in a denominator: =SUMPRODUCT((A2:A20="East")/COUNTIFS(A2:A20,A2:A20,B2:B20,B2:B20)) – but this is advanced. A simpler approach for Excel 365 is to use COUNTA(UNIQUE(FILTER(...))).
Why does my SUMIFS return 0? Check for leading/trailing spaces in your data, number stored as text, or criteria that don't match exactly. Use TRIM and CLEAN on the data if needed.
Can I use cell references for criteria? Yes, and it's best practice. Use =SUMIFS(B2:B20, A2:A20, E1) where E1 contains "East". For operators, concatenate: "&E2 where E2 contains ">100".
Do these functions work in Google Sheets? Yes, SUMIFS, COUNTIFS, and AVERAGEIFS exist in Google Sheets with the same syntax, though the menu paths for conditional formatting differ.
What about MAXIFS and MINIFS? These were added in Excel 2019 and Microsoft 365. They work exactly like SUMIFS but return the maximum or minimum value that meets the criteria.
Alternatives for Complex Logic
If your criteria involve dynamic arrays, OR logic, or you need to return multiple results, consider FILTER (Excel 2021/365) combined with SUM, COUNT, or AVERAGE. For example, =SUM(FILTER(B2:B20, (A2:A20="East")*(C2:C20="Widget"))) does the same as SUMIFS but is more flexible if you later want to manipulate the filtered array. For older Excel versions, SUMPRODUCT remains a fallback, but it can be slower with large datasets.
Related
- Java String Length: How to Get String Length
- Format String in Business Central: Syntax & Examples
- Big Birthday Number Balloons: Sizes, Styles & How to Choose
Try it: the Formula Explainer: paste any formula and see each function and reference in plain English.
More in Formulas & functions
- Excel Sheet Number Sequence: How to Create OneTo create a number sequence in an Excel worksheet, put =SEQUENCE(10) in a blank cell with room below…
- Excel Table Names in Formulas: How to Use Them WellYes. In Excel for Microsoft 365 on Windows, use a table name and its column header in a…
- XLOOKUP Multiple Columns: How to Return or Match ThemTo look up multiple columns with XLOOKUP, you have two main goals: returning values from several columns at…
- Excel MID Function From the Right: Formulas That WorkNo: Excel’s MID function always counts characters from left to right. To take a fixed number of characters…
- Countif Empty Cells: Excel Formula & GuideTo count empty cells in Excel, use the COUNTBLANK function: =COUNTBLANK(range). For example, =COUNTBLANK(A1:A10) returns the number of…
- Excel SUMIF Criteria Examples for Text, Dates, and NumbersExcel’s SUMIF function adds values when one matching condition is true. With categories in A2:A7 and amounts in…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.