To add values that match a condition in Google Sheets, use SUMIF, not COUNTIF. With item names in A2:A7 and amounts in B2:B7, this formula adds the amounts for rows labeled Apples: =SUMIF(A2:A7,"Apples",B2:B7).
What “sum COUNTIF” can mean
The phrase “sum COUNTIF” can describe two different tasks. You might want to add numbers from rows that meet a condition, such as total sales for one product. That is a SUMIF task. Or you might want to count matching cells, or add the results of several counts. Those tasks use COUNTIF, sometimes combined with addition or other functions.
The distinction matters because COUNTIF returns how many cells match; it does not add the values in those cells. For example, if three rows say Apples and their amounts are 12, 15, and 9, a count is 3 while the sum is 36. Choosing the function based on the result you need avoids a formula that looks plausible but answers the wrong question.
In short, use SUMIF to total values selected by one condition, SUMIFS for multiple conditions, and COUNTIF or COUNTIFS to count matching cells or rows.
How SUMIF works in Google Sheets
SUMIF checks a range for a condition, then adds the corresponding cells in a sum range. The first range contains the values to test; the condition describes what should match; and the optional sum range contains the numbers to add. If you leave out the sum range, Sheets adds the cells in the criteria range itself, which is useful when that range contains numbers.
For example, when A2:A7 contains product names and B2:B7 contains amounts, the formula in the opening example tests each product name in column A. For every match to Apples, it adds the amount on that same row in column B. If the matching amounts are 12, 15, and 9, the result is 36.
The criteria may be text, a number, a comparison such as “greater than 10,” a cell reference, or a wildcard pattern. Text criteria are usually enclosed in straight double quotes. When a condition uses an operator together with a cell reference, join them with an ampersand so Sheets reads the operator and the cell’s value as one criterion.
Build a basic conditional sum
Suppose a small order list has product names in A2:A7 and order totals in B2:B7. The rows contain Apples/12, Oranges/8, Apples/15, Pears/6, Apples/9, and Oranges/5. To total just the Apple orders, use:
With product names in A2:A7 and order totals in B2:B7, enter: =SUMIF(A2:A7,"Apples",B2:B7). The result is 36, because 12 + 15 + 9 = 36.
To adapt this example, replace the ranges with the columns in your own sheet and replace Apples with the criterion you need. You can also put the criterion in a cell. If D2 contains Apples, use the following version to make it easier to change the selected product without editing the formula:
With product names in A2:A7, order totals in B2:B7, and the requested product in D2, use: =SUMIF(A2:A7,D2,B2:B7). If D2 contains Apples, the result is again 36.
Keep the criteria range and sum range aligned: each row in one should correspond to the same row in the other. A useful habit is to select both ranges from the same first row through the same last row, especially when copying a formula down or extending a table.
Sum values that meet multiple conditions
When a total must satisfy two or more conditions at once, use SUMIFS. It adds a sum range only for rows that meet every listed condition. For instance, a report might need the total for Apples in the East region, rather than all Apple orders or all East orders.
Assume A2:A7 holds products, B2:B7 holds regions, and C2:C7 holds amounts. The rows are Apples/East/12, Apples/West/15, Apples/East/9, Oranges/East/8, Apples/West/7, and Pears/East/6. The matching East Apple amounts are 12 and 9:
With product names in A2:A7, regions in B2:B7, and amounts in C2:C7, use: =SUMIFS(C2:C7,A2:A7,"Apples",B2:B7,"East"). The result is 21.
Notice the argument order: SUMIFS starts with the sum range, then takes a criteria range and criterion pair for each condition. This differs from SUMIF, where the criteria range comes first. All the ranges should cover the same rows so the conditions and amounts stay associated with the correct records.
When you really need COUNTIF
If your goal is to find how many times a value appears, COUNTIF is the right function. Using the product list in A2:A7 from the earlier example, there are three cells containing Apples:
With product names in A2:A7, use: =COUNTIF(A2:A7,"Apples"). The result is 3. It counts matching cells and does not look at the order totals in column B.
If you need to add separate counts for two categories, add the individual COUNTIF results. With product names in A2:A7, use: =COUNTIF(A2:A7,"Apples")+COUNTIF(A2:A7,"Pears"). The result is 4: three Apple rows plus one Pear row. This is a sum of counts, not a sum of order amounts.
For the corresponding total of the amounts for Apples and Pears, add two conditional sums instead. With product names in A2:A7 and order totals in B2:B7, use: =SUMIF(A2:A7,"Apples",B2:B7)+SUMIF(A2:A7,"Pears",B2:B7). The result is 42: the Apple total of 36 plus the Pear amount of 6. Being precise about whether the answer should be a number of rows or a total of values is the key decision.
Use comparison criteria, wildcards, and dates
For numeric tests, put the comparison operator and number inside the quoted criterion. If you want to add values greater than 10 in a numeric range, that same range can serve as both the test range and sum range.
With numbers in B2:B7, use: =SUMIF(B2:B7,">10",B2:B7). In the order example, the values greater than 10 are 12 and 15, so the result is 27. Other useful operators include less than, greater than or equal to, less than or equal to, and not equal to.
You can also build a comparison from a cell. With values in B2:B7 and a cutoff number in D2, use: =SUMIF(B2:B7,">"&D2,B2:B7). If D2 contains 10, this returns 27 for the same data. The ampersand joins the greater-than sign to the value held in D2.
Wildcards help when text labels are not identical. An asterisk matches any number of characters, while a question mark matches one character. With product names in A2:A7 and amounts in B2:B7, use =SUMIF(A2:A7,"Ap*",B2:B7) to sum labels beginning with Ap; in the example, the result is 36. Wildcards are useful for names with varying endings, but use an exact criterion when partial matches could include unwanted categories.
For date criteria, use real date values rather than relying on how dates look when displayed. With dates in A2:A100, amounts in B2:B100, and a desired month of January 2026, use: =SUMIFS(B2:B100,A2:A100,">="&DATE(2026,1,1),A2:A100,"<"&DATE(2026,2,1)). This includes dates from January 1 up to, but not including, February 1, so it works even if cells contain times as well as dates.
Common problems and how to fix them
- The formula counts but does not total. Check whether you used
COUNTIFwhen you meant to add a separate numeric column. UseSUMIFwith the numeric column as its sum range. - The result is zero unexpectedly. Confirm the criterion matches the underlying value. Extra spaces, different spelling, or a number stored as text can prevent an expected match. Check a sample cell directly and clean inconsistent source data if needed.
- Amounts are omitted or paired with the wrong label. Make sure criteria and sum ranges cover corresponding rows, and that neither range starts or ends on a different row. Avoid including a header in one range but not the other.
- A comparison is treated as text. For a condition based on a cell, join the operator and reference with
&. A criterion that contains only a fixed comparison can be written as text in quotes. - A date filter misses records. Confirm the cells contain actual date values, not text that merely looks like a date. For a whole-month test, use a start date inclusive and the next month’s start as an exclusive boundary.
- The formula separator is rejected. Google Sheets normally displays formulas with commas in many locales, but spreadsheet locale settings can require semicolons as argument separators. If Sheets reports a formula parse error, check the locale under File > Settings.
Google Sheets in a web browser uses the same core SUMIF, SUMIFS, and COUNTIF logic as Excel. The interface and some locale-specific formula separators may differ, but the examples here use the common comma-separated syntax.
Alternatives for more specialized conditions
For the usual task of matching values in several columns, SUMIFS is the clearest choice. It makes each condition visible and is generally easier to read later than a long expression. If the condition includes calculations or logic that do not fit a straightforward criteria-range test, SUMPRODUCT can be an alternative, though it can be harder to maintain.
With products in A2:A7, regions in B2:B7, and amounts in C2:C7, the following sums rows where the product is Apples and the region is East: =SUMPRODUCT((A2:A7="Apples")*(B2:B7="East")*C2:C7). The result for the example data is 21. Each condition produces a match test, and multiplying those tests keeps amounts only where both tests are true. For ordinary multi-condition totals, the equivalent SUMIFS formula is usually easier for another person to understand.
There is no need to use an alternative simply because the formula contains a condition. Start with SUMIF for one criterion and SUMIFS for several; switch only when the task requires a different kind of logic or a different output.
Frequently Asked Questions
Can COUNTIF add numbers in Google Sheets?
No. COUNTIF returns the number of cells that meet a condition. To add values from matching rows, use SUMIF or, for multiple conditions, SUMIFS.
What is the difference between SUMIF and SUMIFS?SUMIF is designed for one condition, while SUMIFS can apply several conditions to the same rows. In SUMIFS, the sum range comes first, followed by condition-range and criterion pairs.
Can I use a cell reference as the SUMIF condition?
Yes. Put the reference in the criterion argument instead of typing a fixed text value. This lets you change the selected category in a cell without rewriting the formula.
How do I sum values that match either of two categories?
For two exact categories, add two separate SUMIF results, one for each category. If you are asking how many rows match either category rather than how much they total, add the corresponding COUNTIF results.
Why does SUMIF return zero when matching rows exist?
Common causes include extra spaces or inconsistent text, a criterion that does not match the stored value, a range that points to the wrong column, or numbers stored as text. Check a matching row and verify the criteria range and sum range before changing the formula.
Related
- Google Sheets Inventory Spreadsheet: Setup and Tips
- Inventory Spreadsheet: Simple Setup and Useful Tips
- Inventory List Spreadsheet Template: Build and Use One
Try it: the Date Difference Calculator: days, months, years and weekdays between two dates, with the DATEDIF formulas.
More in How-to basics
- Excel Row Count Limit: Maximum Rows and What It MeansIn current versions of Microsoft Excel, a worksheet can contain up to 1,048,576 rows. That is the limit…
- Currency Rate in Google Sheets: Formulas and TipsTo get a currency rate in Google Sheets, use the GOOGLEFINANCE function with a currency pair, such as…
- How to Delete a Second Blank Page in Microsoft WordTo delete a second blank page in Word, turn on formatting marks with Home > ¶ Show/Hide, find…
- How to Export Shared Contacts in Outlook to a FileTo export shared contacts in Outlook, open the shared Contacts folder in classic Outlook for Windows, then use…
- Excel Track Changes: How to Turn It OnTo turn on the traditional Track Changes mode in Excel for Microsoft 365 on Windows, open the workbook,…
- Google Sheets Weekly Timesheet Template: Setup TipsYes. You can make a weekly timesheet template in Google Sheets by creating a table for each day,…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.