To sum with multiple criteria in Google Sheets, use SUMIFS (with an S), not SUMIF. For example, =SUMIFS(C2:C10, A2:A10, "East", B2:B10, ">100") sums values in C2:C10 where column A equals “East” and column B is greater than 100. This article explains the syntax, common mistakes, and alternatives like SUMPRODUCT and QUERY.
Why SUMIF Falls Short
The single-criteria SUMIF function accepts only one condition range and one criterion. If you try to add a second condition range, the function ignores it or returns an error. Google Sheets introduced SUMIFS specifically to handle multiple criteria. The key difference: SUMIF has the sum range last, while SUMIFS has the sum range first. This ordering trips up many users who switch between the two.
SUMIFS Syntax and Real Examples
The syntax is: =SUMIFS(sum_range, criteria_range1, criterion1, [criteria_range2, criterion2, ...]). You can add up to 127 pairs of criteria ranges and criteria. Here are concrete examples:
- Two text criteria: With sales in B2:B20, region in A2:A20, and product in C2:C20, use
=SUMIFS(B2:B20, A2:A20, "North", C2:C20, "Widget")to sum sales for North region Widgets. - Numeric and date criteria: With dates in A2:A20 and amounts in B2:B20, use
=SUMIFS(B2:B20, A2:A20, ">="&DATE(2024,1,1), A2:A20, "<="&DATE(2024,12,31))to sum amounts in 2024. - Wildcard criteria: Use
*for any sequence and?for a single character.=SUMIFS(B2:B20, A2:A20, "*Corp")sums amounts for any region ending in "Corp".
Note that criteria are case-insensitive. "east" matches "East". If you need case-sensitive matching, use SUMPRODUCT with EXACT.
How to Use Cell References as Criteria
Instead of typing criteria directly, reference cells. For example, with the region in D1 and product in D2, use =SUMIFS(B2:B20, A2:A20, D1, C2:C20, D2). If your criterion is a comparison operator, concatenate it with the cell reference: =SUMIFS(B2:B20, A2:A20, ">="&D1). This works because the ampersand (&) joins the text operator with the cell value. A common mistake is writing ">=D1" which treats "D1" as literal text, not a cell reference.
Common Problems and Fixes
Several issues trip up users:
- Sum range and criteria range sizes differ: All ranges must have the same number of rows and columns. If they don't, you'll get a #VALUE! error.
- Mixing SUMIF and SUMIFS order: In SUMIF, the sum range is the third argument. In SUMIFS, it's the first. Double-check the order.
- Using AND vs OR logic: SUMIFS requires all criteria to be true (AND logic). To sum when any one of several criteria is true (OR logic), you need to add multiple SUMIFS together or use SUMPRODUCT. For example, to sum sales for either "North" or "South", use
=SUMIFS(B2:B20, A2:A20, "North") + SUMIFS(B2:B20, A2:A20, "South"). - Blank cells and zeros: A blank cell in a criteria range is treated as 0. If you want to match truly blank cells, use
""as the criterion. To match non-blank cells, use"<>".
SUMPRODUCT as a Flexible Alternative
When SUMIFS feels limiting, SUMPRODUCT offers more control. It multiplies arrays and sums the results. For example, to sum sales where region is "East" and product is "Widget", use =SUMPRODUCT((A2:A20="East")*(C2:C20="Widget")*B2:B20). The comparisons return TRUE/FALSE, which multiply as 1/0. This works for OR logic too: =SUMPRODUCT(((A2:A20="East")+(A2:A20="West"))*B2:B20) sums sales for East or West. SUMPRODUCT also handles case-sensitive matching with EXACT: =SUMPRODUCT(EXACT(A2:A20,"East")*B2:B20). However, SUMPRODUCT can be slower on very large datasets because it processes each row as an array.
Using QUERY for Complex Conditions
Google Sheets' QUERY function uses a SQL-like language for powerful aggregation. For instance, to sum sales by region and product with a filter, you could write =QUERY(A2:C20, "select A, C, sum(B) where A = 'East' group by A, C label sum(B) 'Total'"). QUERY is especially useful when you need to group results or apply multiple conditions in a single formula. The downside: the syntax is more complex, and you must be careful with quoting strings (single quotes for text, double quotes for the whole query). It also returns a header row by default, which you can suppress with label or by using offset 1.
Comparing SUMIFS, SUMPRODUCT, and QUERY
Choose the right tool based on your needs:
- SUMIFS is best for simple AND logic with a few criteria. It's fast, easy to read, and the standard choice.
- SUMPRODUCT is best for OR logic, case-sensitive matches, or when you need to manipulate criteria with arithmetic (like checking if a value is between two numbers using
(A2:A20>=10)*(A2:A20<=20)). - QUERY is best for grouped summaries, sorting, or when you need to return multiple columns along with the sum. It's also handy when you want to avoid helper columns.
For most users, SUMIFS is the go-to. Use SUMPRODUCT when you hit its limits, and QUERY when you need a full report.
Frequently Asked Questions
Can I use SUMIFS with OR logic?
No, SUMIFS only applies AND logic. To sum when any one condition is true, add multiple SUMIFS together, or use SUMPRODUCT with the plus operator as shown above.
How do I sum if a cell contains text from a list?
Use wildcards with SUMIFS. For example, to sum sales for products starting with "Pro", use =SUMIFS(B2:B20, C2:C20, "Pro*"). For a list of specific values, you can use SUMPRODUCT with MATCH: =SUMPRODUCT(ISNUMBER(MATCH(C2:C20, {"Widget","Gadget"}, 0))*B2:B20).
Why does my SUMIFS return 0?
Check that your criteria match exactly. Text criteria are case-insensitive but must match spelling and any leading/trailing spaces. Also verify that your sum range contains numbers, not text that looks like numbers. Use the ISNUMBER function to test a cell.
Can I use SUMIFS across multiple sheets?
Yes, but you must reference each sheet separately. For example, to sum sales from Sheet1 and Sheet2, use =SUMIFS(Sheet1!B2:B20, Sheet1!A2:A20, "East") + SUMIFS(Sheet2!B2:B20, Sheet2!A2:A20, "East"). There's no direct way to use a 3D reference across sheets with SUMIFS.
What's the difference between SUMIF and SUMIFS in Google Sheets?
SUMIF sums a range based on one criterion, with the sum range as the third argument. SUMIFS sums based on multiple criteria, with the sum range as the first argument. SUMIFS is more flexible and generally preferred even for a single criterion, as it keeps the sum range first.
Related
- Google Sheets IMDIV Function: Syntax & Examples
- Google Sheets SUMIF Between Two Dates (Formula & Examples)
- Balance Sheet in QBO: What It Is & How to Read It
Try it: the Date Difference Calculator: days, months, years and weekdays between two dates, with the DATEDIF formulas.
More in How-to basics
- Translate Google Sheets to English: Formulas, Steps and TipsTo translate text in Google Sheets into English, enter a formula such as =GOOGLETRANSLATE(A2,"auto","en") in an empty cell,…
- Outlook AutoArchive: How to Set It Up AutomaticallyTo set up scheduled email archiving, open classic Outlook for Windows and go to File > Options >…
- How to Insert an Image in Excel Without Moving CellsTo keep an image from moving or changing size when you adjust worksheet cells, insert it as a…
- Excel Value Formatting: What It Changes and How to Use ItIn Excel, value formatting changes how a stored number, date, or text value appears in a cell; it…
- Can You Lock Certain Cells in Google Sheets? Here’s HowYes. In Google Sheets in a web browser, select the cells, choose Data > Protect sheets and ranges,…
- Excel Power Query Refresh: Does It Load Only New Data?No. In Excel for Microsoft 365, a normal Power Query refresh reruns the query against its source and…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.