To sum cells in Google Sheets only when they contain a number, use SUMIF with a criterion like >0 or <> (not empty), or use SUMIFS with ISNUMBER logic via SUMPRODUCT. The simplest formula is =SUMIF(A2:A10, ">0"), which sums only numeric values greater than zero in the range.
Why SUMIF Is the Go-To Function
Google Sheets’ SUMIF function adds numbers in a range that meet a single condition. Its syntax is SUMIF(range, criterion, [sum_range]). When the range you want to sum is the same as the range you’re testing, you can omit sum_range. The criterion can be a number, expression, or text. For example, to sum only positive numbers in A1:A10, use =SUMIF(A1:A10, ">0"). This works because any cell containing text or a blank is ignored—only numeric values are evaluated against the criterion.
Handling Text, Blanks, and Errors
A common misconception is that SUMIF with >0 excludes negative numbers, which is true. But what if you want to sum all numeric cells, including negatives and zero? Use the criterion <> (not equal to nothing) or <>"". However, <> alone also includes text cells, which would cause a #VALUE! error. To sum only numeric cells regardless of sign, use SUMPRODUCT with ISNUMBER:
=SUMPRODUCT(ISNUMBER(A1:A10)*A1:A10)
This formula multiplies each cell by 1 if it’s a number (TRUE) or 0 if not (FALSE), then sums the results. It ignores text, blanks, and error values (though errors in the range will still propagate).
Using SUMIFS for Multiple Conditions
If you need to sum numbers that also meet other criteria, use SUMIFS. For example, to sum only positive numbers in column A where column B equals “Yes”:
=SUMIFS(A1:A10, A1:A10, ">0", B1:B10, "Yes")
Here, the first argument is the sum range, then pairs of criteria ranges and criteria. This is more flexible than SUMIF and works in both Google Sheets and Excel (though Excel uses the same syntax).
How to Choose Between SUMIF, SUMIFS, and SUMPRODUCT
- SUMIF – Use when you have one condition and you’re summing the same range you’re testing.
- SUMIFS – Use when you have multiple conditions, even if one is numeric.
- SUMPRODUCT with ISNUMBER – Use when you need to sum all numeric cells regardless of value, or when you need to ignore text without extra conditions.
For most cases, SUMIF with >0 is sufficient because you rarely want to sum negative numbers accidentally. But if your data includes both positive and negative numbers and you want the total of all numeric entries, the SUMPRODUCT approach is safer.
Common Problems and Fixes
If your SUMIF returns 0 or an error, check these issues:
- Text-formatted numbers: Cells may look like numbers but are stored as text. Use
VALUE()to convert, or select the column and use Data > Split text to columns > Tab to force conversion. - Leading apostrophes: A leading apostrophe (‘) makes a cell text. Remove it by editing the cell.
- Errors in the range: If any cell contains #N/A or #DIV/0!,
SUMIFwill ignore it, butSUMPRODUCTwill propagate the error. UseIFERRORinside the array. - Wrong range size: Ensure the sum range and criteria range are the same size, or you’ll get a #VALUE! error.
Google Sheets vs. Excel Differences
The functions SUMIF, SUMIFS, and SUMPRODUCT work identically in both Google Sheets and Microsoft Excel. The main difference is in how you enter array formulas: in Excel, you might need to press Ctrl+Shift+Enter for older versions, but Google Sheets handles arrays natively. Also, Google Sheets uses FILTER and ARRAYFORMULA differently, but for summing, the syntax is the same. If you’re working in Excel, be aware that SUMPRODUCT with ISNUMBER is a classic array formula that works without special entry in Excel 365.
Practical Examples and Formulas
Assume you have a list of sales amounts in A2:A20, with some cells containing text like “N/A” or blanks. To sum only the numeric sales:
- Use
=SUMIF(A2:A20, ">0")– sums only positive numbers (ignores negatives, text, blanks). - Use
=SUMIF(A2:A20, "<>")– sums all numbers but also includes text, causing an error if any text exists. - Use
=SUMPRODUCT(ISNUMBER(A2:A20)*A2:A20)– sums all numeric values, ignoring text and blanks.
For a more robust approach that also handles errors, use =SUMPRODUCT(IFERROR(ISNUMBER(A2:A20)*A2:A20, 0)) as an array formula (press Ctrl+Shift+Enter in Excel, but in Google Sheets it works normally).
Frequently Asked Questions
Can I sum cells that contain numbers mixed with text like “$5”?
No, because “$5” is text. You’d need to extract the number using VALUE or REGEXEXTRACT. For example, =SUM(ARRAYFORMULA(VALUE(REGEXEXTRACT(A1:A10, "[0-9.]+")))).
How do I sum only numbers greater than a specific value, like 100?
Use =SUMIF(A1:A10, ">100"). The criterion can be any number or expression.
Why does my SUMIF return 0 even though there are numbers?
Check if the numbers are stored as text. Select the range, look for a warning icon, and convert to number. Also ensure the criterion matches the data type.
Can I sum based on a cell reference for the threshold?
Yes, use concatenation: =SUMIF(A1:A10, ">"&B1) where B1 contains the threshold number.
Does SUMIF work with dates?
Yes, dates are numbers in Google Sheets. Use criteria like ">"&DATE(2024,1,1) to sum dates after a certain day.
Is there a way to sum only visible cells after filtering?
Yes, use SUBTOTAL(109, range) to sum only visible cells. This is different from SUMIF, which ignores filters.
Final Thoughts on Summing Numeric Cells
The best formula depends on your data and what you mean by “contains a number.” If you want to exclude text and blanks but include negatives, SUMPRODUCT(ISNUMBER(range)*range) is your friend. If you only want positive values, SUMIF(range, ">0") is simpler. Always test on a small sample to confirm the results match your expectation.
Related
- Budget and Balance Sheet: Key Differences
- Split Name into Two Columns in Google Sheets
- Data Entry KPH: Meaning, Tests, and Good Scores
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 Delete an Excel File from a SharePoint SiteTo delete an Excel workbook from SharePoint, open the document library that contains it, select the workbook, choose…
- Excel New Sheet: How to Add and Open OneTo add a new worksheet in Excel for Microsoft 365 on Windows, click the plus sign beside the…
- Google Sheets Data Cleaning: Tools, Steps, and TipsGoogle does not make a product called Google Excel: its spreadsheet app is Google Sheets, and it includes…
- Google Sheets Filter Blanks: How to Find Empty CellsYes. In Google Sheets, select your data, choose Data > Create a filter, open the filter icon in…
- Java Code to Compare Two Excel Files with Apache POITo compare two Excel workbooks in Java, use Apache POI to open each file, match sheets by name,…
- Excel MAXIFS: Find the Highest Value by CriteriaTo find the largest value in an Excel range that meets a condition, use MAXIFS. For example, with…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.