The direct answer: In Google Sheets, use the SUMIF function to sum numbers in a range only when a corresponding condition is true. The syntax is =SUMIF(range, criterion, [sum_range]) — for example, =SUMIF(A2:A10, "Yes", B2:B10) adds all values in B2:B10 where the matching cell in A2:A10 equals “Yes”.
What SUMIF Does and Why It Matters
SUMIF is one of the most-used functions in Google Sheets because it turns a plain column of numbers into a conditional total. Instead of manually filtering data or writing a long IF formula for each row, you give SUMIF three pieces of information: where to look, what to look for, and which numbers to add. The function checks each cell in the first range against your criterion; when the check is true, it includes the corresponding value from the sum range in the total.
This is especially useful for budgets, sales logs, attendance sheets, or any dataset where you need totals for a specific category. For instance, if you track expenses with a column for category and a column for amount, SUMIF can instantly give you the total spent on “Groceries” without sorting or filtering.
SUMIF Syntax and Arguments Explained
The function takes three arguments, and the third is optional in a specific way:
- range — the cells you want to check against the condition. This can be a single column, row, or a rectangular block.
- criterion — the condition that determines which cells are “true.” It can be a number, text, a cell reference, or a logical expression like
">10"or"<>Pending". - sum_range — the cells to add together. If you omit it, SUMIF sums the range itself.
Important: If you include a sum_range, it should be the same size and shape as the range. Google Sheets will use the top-left cell of the sum_range and extend it to match the range’s dimensions, but it’s safer to make them exactly the same size to avoid unexpected results.
How to Use SUMIF: Step-by-Step with Examples
Let’s walk through a practical example. Suppose you have a list of sales in columns A and B:
- A2:A20 contains product names (e.g., “Widget”, “Gadget”)
- B2:B20 contains the dollar amount for each sale
To sum all sales of “Widget”, you would enter:
=SUMIF(A2:A20, "Widget", B2:B20)
This returns the total of all B values where the corresponding A cell is exactly “Widget”. The match is case-insensitive by default, so “widget” and “WIDGET” both count.
For a numeric condition, say you want the total of all sales over $100. You would use:
=SUMIF(B2:B20, ">100")
Here, because you omit the sum_range, it sums the cells in B2:B20 that meet the criterion. The result is the sum of all amounts greater than 100.
You can also reference a cell for the criterion. If C1 contains “Widget”, then =SUMIF(A2:A20, C1, B2:B20) works the same as typing the text directly.
Common Problems and How to Fix Them
Several issues trip up new users:
- Text criteria with operators: If you use a comparison like
">=100", it treats the whole string as a number comparison. For text, you can use wildcards:"*Widget*"matches any cell containing “Widget”. - Case sensitivity: SUMIF is not case-sensitive. If you need case-sensitive matching, you must use
SUMIFSwith anEXACThelper or useFILTERwithEXACT. - Blank cells: A criterion of
""sums cells that are blank, while"<>"sums non-blank cells. - Wrong sum_range size: If sum_range is smaller than range, Google Sheets extends it from the top-left, which can cause #VALUE! errors or wrong totals. Always double-check sizes.
- Using SUMIF with dates: Dates are stored as numbers in Sheets, so you can use criteria like
">="&DATE(2025,1,1)to sum dates after a certain day.
SUMIF vs. SUMIFS: Which One Should You Use?
SUMIF handles a single condition. If you need to sum based on two or more conditions, use SUMIFS. The syntax is different: =SUMIFS(sum_range, criteria_range1, criterion1, [criteria_range2, criterion2, ...]). For example, to sum sales of “Widget” in the “East” region (with region in C2:C20):
=SUMIFS(B2:B20, A2:A20, "Widget", C2:C20, "East")
Notice that SUMIFS puts the sum_range first, while SUMIF puts it last. This is a common source of errors when switching between them. In general, use SUMIF for a single condition and SUMIFS for multiple — SUMIFS also works for a single condition, but it’s more verbose.
Alternatives: FILTER, QUERY, and Pivot Tables
SUMIF is not the only way to sum conditionally. Depending on your needs, consider:
- FILTER + SUM:
=SUM(FILTER(B2:B20, A2:A20="Widget"))returns the same result and allows more complex logic (like OR conditions) that SUMIF can’t handle directly. - QUERY:
=QUERY(A1:B20, "select sum(B) where A = 'Widget' label sum(B) ''")is powerful for large datasets and offers SQL-like flexibility. - Pivot Tables: For ad-hoc analysis, a pivot table can group and sum data without formulas, but it’s not dynamic in the same way unless you refresh it.
Each method has trade-offs: SUMIF is simple and fast; FILTER is more flexible; QUERY is powerful but has a steeper learning curve; pivot tables are great for interactive exploration.
Frequently Asked Questions
Can I use SUMIF with text that contains partial matches? Yes, use wildcards. An asterisk (*) matches any sequence of characters, and a question mark (?) matches any single character. For example, =SUMIF(A2:A20, "*Widget*", B2:B20) sums all rows where column A contains the word “Widget” anywhere.
Why is my SUMIF returning 0? Common reasons: the criterion doesn’t match exactly (e.g., extra spaces), the sum_range is misaligned, or the range contains text numbers. Check for leading/trailing spaces by using =TRIM(), and verify that the numbers are stored as numbers (not text) by using =ISNUMBER().
Can SUMIF sum based on a cell color or font color? No. SUMIF only works with cell values, not formatting. To sum by color, you’d need to use Google Apps Script or a workaround like adding a helper column with a formula that checks the color (which is not natively possible without scripts).
Is SUMIF case-sensitive? No, by default it is not. If you need case-sensitive matching, combine SUMPRODUCT with EXACT: =SUMPRODUCT(--(EXACT(A2:A20, "Widget")), B2:B20).
How do I sum if a cell is not blank? Use =SUMIF(A2:A20, "<>", B2:B20). The criterion “<>” means “not empty.” To sum only blank cells, use “” as the criterion.
Final Tips for Using SUMIF Effectively
To get the most out of SUMIF, keep these pointers in mind:
- Always use absolute references (like
$A$2:$A$20) if you plan to copy the formula to other cells. - For large datasets, SUMIF is efficient, but if you need to sum across multiple sheets, consider using
SUMIFwith a 3D reference or combine withINDIRECT. - Remember that SUMIF ignores cells with text in the sum_range when the criterion is numeric; it treats them as 0.
- If you’re working with dates, make sure the criterion uses the date serial number or a DATE function, not a text string like “1/1/2025” unless you format it correctly.
With these basics, you can confidently sum any subset of your data based on a condition, saving time and reducing manual errors.
Related
- Google Sheets Sum Entire Column: Easy Formula
- Data Entry VA: What It Is, Duties & How to Hire One
- Random 8 Digit Code: How to Generate and Use Them
Try it: the Date Difference Calculator: days, months, years and weekdays between two dates, with the DATEDIF formulas.
More in How-to basics
- How to Add a Watermark to Both Pages in Microsoft WordIn Word for Microsoft 365, choose Design > Watermark and select a preset, or open Custom Watermark to…
- Fed Reserve Balance Sheet: How It WorksThe Federal Reserve’s balance sheet is a quarterly financial statement that lists the central bank’s assets (mostly Treasury…
- Shortcut to Highlight in Excel? Quick Keys & TricksThe fastest shortcut to highlight cells in Excel for Microsoft 365 on Windows is Ctrl+Shift+L to toggle filters…
- Scatter Plot in Excel: Create, Format, and Read ItTo create a scatter plot in Excel for Microsoft 365 on Windows, put your X values in one…
- How to Split Merged Cells in Google Sheets SafelyTo split merged cells in Google Sheets, select a merged cell, then choose Format > Merge cells >…
- Outlook Calendar: How to Find and Remove DuplicatesYes—duplicate Outlook calendar events can be removed by deleting the extra entries, but Outlook does not offer one…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.