Use =SUMIF(range, criteria, sum_range) to sum a category in a column in Google Sheets. For example, with categories in A2:A20 and amounts in B2:B20, =SUMIF(A2:A20, "Food", B2:B20) returns the total of all rows where column A says “Food”.
Why SUMIF Is the Right Tool
Google Sheets has several functions that add numbers, but only one is built specifically for a single category match. SUMIF checks a range against one condition and sums a second range. It is the direct answer to “sum a category in a column” because it lets you point at the category column, type the category name, and point at the value column. The function works in Excel too, but this article follows Google Sheets in a browser, where the syntax and behavior are identical.
If you need to sum multiple categories at once, use SUMIFS (with an S) or a pivot table. But for a single category, SUMIF is simpler and faster to write.
How SUMIF Works Step by Step
The function takes three arguments, and the third one is optional in some cases but required for summing a separate column.
- range – the cells to check for the category (e.g., A2:A20)
- criteria – the category name, typed as text in quotes, or a cell reference
- sum_range – the cells to add up (e.g., B2:B20)
Example layout: Column A has category names (Food, Travel, Utilities), column B has amounts. Put this in D2:
=SUMIF(A2:A20, "Food", B2:B20)
If your sheet has 10 rows of data, this returns the sum of B2:B20 only where A2:A20 equals “Food”. The result updates automatically when you edit the data.
Using a Cell Reference for the Category
Hard-coding “Food” in the formula works, but a better practice is to put the category name in a cell and reference it. This lets you change the category without editing the formula.
With the category name in D1, use:
=SUMIF(A2:A20, D1, B2:B20)
Now type “Travel” in D1 and the sum updates. This is especially useful when you build a small dashboard or a summary table with several categories listed in column D.
Handling Partial Matches and Wildcards
SUMIF treats text criteria as exact matches by default. If you want to sum all categories that contain a word, use wildcards. The asterisk (*) matches any sequence of characters, and the question mark (?) matches a single character.
To sum all rows where the category contains “food” (like “Food”, “Food & Drink”, “Pet Food”):
=SUMIF(A2:A20, "*food*", B2:B20)
Note that this is case-insensitive in Google Sheets, so “FOOD” also matches. If you need case-sensitive matching, you must use a different approach, such as SUMPRODUCT with EXACT.
Common Mistakes and How to Fix Them
Several errors trip up new users. Here are the most frequent ones and the solutions.
- Wrong range sizes – range and sum_range must be the same size. If A2:A20 and B2:B10, the formula returns a #VALUE! error. Fix by making both ranges the same length.
- Text vs. number criteria – If your category is a number (like 101), type it without quotes:
=SUMIF(A2:A20, 101, B2:B20). If you type “101” as text, it may not match numeric cells. - Leading/trailing spaces – A category like “Food ” with a space won’t match “Food”. Use
=SUMIF(A2:A20, "*Food*", B2:B20)or clean the data with TRIM. - Using SUMIFS incorrectly – SUMIFS has a different argument order: sum_range comes first. Don’t confuse the two.
When to Use SUMIFS Instead
SUMIFS sums rows that meet multiple criteria. For example, sum amounts where category is “Food” and month is “January”. The syntax is:
=SUMIFS(sum_range, criteria_range1, criteria1, [criteria_range2, criteria2, ...])
With categories in A2:A20, months in B2:B20, and amounts in C2:C20:
=SUMIFS(C2:C20, A2:A20, "Food", B2:B20, "January")
This returns the total for Food in January. SUMIFS is available in Google Sheets and Excel 2019 or later. If you have only one criterion, SUMIF is simpler, but SUMIFS works fine as well.
Alternatives: Pivot Tables and QUERY
For a quick one-off sum, SUMIF is perfect. But if you need a full breakdown by category, a pivot table is more flexible. Select your data, go to Insert > Pivot table, then drag the category column to Rows and the amount column to Values. The pivot table sums each category automatically and lets you filter, sort, and format without writing formulas.
Another powerful option is the QUERY function, which uses a SQL-like language. To get the same result as the SUMIF example:
=QUERY(A2:B20, "select A, sum(B) where A is not null group by A label sum(B) 'Total'")
This returns a table of each category and its total. QUERY is more advanced but can handle multiple aggregations and conditions in one formula.
Frequently Asked Questions
Can I sum a category with a partial match in Google Sheets?
Yes, use wildcards. =SUMIF(A2:A20, "*food*", B2:B20) sums all rows where column A contains “food” anywhere. The match is case-insensitive. To make it case-sensitive, you’d need a more complex formula with SUMPRODUCT and EXACT.
Why does my SUMIF return 0 even though I have matching data?
Most likely a text vs. number mismatch or invisible spaces. Check that the category in the criteria matches exactly, including spaces. Use TRIM on the data column if needed. Also ensure the sum_range contains numbers, not text that looks like numbers.
Does SUMIF work with dates?
Yes. For a date criterion, use a date reference or a date function. For example, =SUMIF(A2:A20, DATE(2025,1,1), B2:B20) sums rows where the date in A is exactly January 1, 2025. For a range of dates, you’d need SUMIFS with two criteria like “>=”&DATE(2025,1,1) and “<="&DATE(2025,1,31).
What is the difference between SUMIF and SUMIFS in Google Sheets?
SUMIF takes one criterion and has the range first, then criteria, then sum_range. SUMIFS takes multiple criteria and puts sum_range first, then pairs of range and criteria. For a single condition, either works, but SUMIF is shorter.
Can I sum a category across multiple sheets?
Not directly with SUMIF. You’d need to use a formula like =SUMIF(Sheet1!A:A, "Food", Sheet1!B:B) + SUMIF(Sheet2!A:A, "Food", Sheet2!B:B) or use a 3D reference with a different function. For many sheets, a pivot table with all sheets combined is easier.
Final Tips for Reliable Sums
Always verify your ranges are the same size and that your criteria match the data type. Use cell references for criteria to make formulas easier to maintain. If you’re summing a large dataset, consider a pivot table for better performance and interactivity. And remember, SUMIF ignores blank cells in the sum_range, so you don’t need to worry about empty rows.
Related
- Sum a Column in Google Sheets: Formulas and Tips
- Google Sheets: How to Create a Sum Column Automatically
- Google Sheets 2D SUMIF: Sum Values by Row and Column
Try it: the Formula Explainer: paste any formula and see each function and reference in plain English.
More in Formulas & functions
- XLOOKUP Tutorial: Examples, Match Modes, and TipsIn Excel for Microsoft 365 on Windows, XLOOKUP searches one range and returns the corresponding value from another:…
- Sort Excel by Column for the Entire WorksheetTo sort a column without separating its rows, click a cell in your data, choose Data > Sort,…
- COUNTIF Excel: Count Duplicates, Repeats, and MatchesYes. In Excel, COUNTIF counts how many times a value appears: with items in A2:A100, enter =COUNTIF($A$2:$A$100,A2) beside…
- SQL String Replace Function: Syntax and ExamplesUse SQL’s REPLACE function to find every occurrence of one text value inside another and substitute different text:…
- Split Lung Function Test: How It Measures Each LungA split lung function test estimates how much each lung contributes to breathing, rather than measuring the lungs…
- Freeze Values in Excel Formulas: A Step-by-Step GuideTo stop a formula result changing, copy the formula cell or range and paste it back as values:…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.