Count and add with COUNTIF and SUMIF in Sheets
Use COUNTIF, SUMIF, COUNTIFS and SUMIFS in Foxcolab Sheets to count or total only the rows that match, with text, number, date and wildcard conditions.
Updated 2 min read
In short
COUNTIF counts the cells that meet a condition, as in =COUNTIF(B2:B6, "Travel"). SUMIF adds the matching rows of another column, as in =SUMIF(B2:B6, "Travel", D2:D6). For two or more conditions, use COUNTIFS or SUMIFS, which put the range to add first. Put operators in quotes (">3000") and join them to cell values with &, as in ">="&G1.
Key takeaways
- COUNTIF(range, criteria) counts matches. SUMIF(range, criteria, sum_range) adds the matching rows of sum_range.
- COUNTIFS and SUMIFS take several range and condition pairs. SUMIFS starts with the range to add.
- Conditions are text in quotes: "Travel", ">3000", "<>Paid", "S*". Capital letters are ignored.
- For dates and cell values, join the operator with &, as in ">="&DATE(2026,4,1).
- Every range in COUNTIFS and SUMIFS must be the same size, or the result is
Last reviewed 5 December 2026
COUNTIF in Foxcolab Sheets counts the cells that meet a condition, and SUMIF adds up the matching rows of another column. Use them to answer questions like "how many travel expenses are there?" and "what did we spend on travel?" without filtering or sorting. Sheets calculates every formula in your browser, so your spreadsheet stays end-to-end encrypted while you work.
The examples use this expense list:
| A | B | C | D | E | |
|---|---|---|---|---|---|
| 1 | Date | Category | Paid by | Amount | Status |
| 2 | 2 Apr 2026 | Travel | Asha | 4200 | Paid |
| 3 | 5 Apr 2026 | Meals | Ravi | 860 | Paid |
| 4 | 9 Apr 2026 | Travel | Ravi | 12500 | Pending |
| 5 | 14 Apr 2026 | Software | Asha | 2999 | Paid |
| 6 | 3 May 2026 | Travel | Asha | 3100 | Pending |
Count matching cells with COUNTIF#
Click an empty cell
For example, G2.
Type the formula
Type =COUNTIF(B2:B6, "Travel"). As you type, Sheets shows a hint with the two arguments: the range to check and the condition.
Press Enter
The cell shows 3, because three rows have Travel in column B.
To browse every conditional function, click Functions in the toolbar and choose All functions…, or choose Insert → Function.
Add up matching rows with SUMIF#
SUMIF takes a third argument: the column to add.
=SUMIF(B2:B6, "Travel", D2:D6) → 19800
=SUMIF(B2:B6, "<>Travel", D2:D6) → 3859
=AVERAGEIF(B2:B6, "Travel", D2:D6) → 6600Leave out the third range to add the checked cells themselves: =SUMIF(D2:D6, ">3000") adds every amount over 3,000, which gives 19800. AVERAGEIF, MAXIFS and MINIFS follow the same pattern. AVERAGEIF shows #DIV/0! when nothing matches.
Use several conditions with COUNTIFS and SUMIFS#
COUNTIFS and SUMIFS count or add only the rows that meet every condition. Give them pairs of a range and a condition:
=COUNTIFS(C2:C6, "Asha", E2:E6, "Paid") → 2
=SUMIFS(D2:D6, B2:B6, "Travel", E2:E6, "Pending") → 15600Write the condition#
| Condition | Matches |
|---|---|
"Travel" | Cells that say Travel, in any capitals |
">3000" | Numbers greater than 3,000. Also "<", ">=", "<=" |
"<>Paid" | Everything except Paid, including empty cells |
"S*" | Text starting with S. * stands for any characters |
"?????" | Text exactly five characters long. ? is one character |
"" | Empty cells |
"<>" | Cells that aren't empty |
"~*" | A real asterisk |
G1 | The same value as cell G1 |
">"&G1 | Numbers greater than the value in G1 |
Dates work the same way when you join the operator to a DATE function. This adds everything spent in April 2026, which gives 20559:
=SUMIFS(D2:D6, A2:A6, ">="&DATE(2026,4,1), A2:A6, "<"&DATE(2026,5,1))Using DATE avoids typing a date as text, which Sheets reads according to the spreadsheet's locale.
Common mistakes#
- The operator is outside the quotes.
=COUNTIF(D2:D6, >3000)is an error. Write">3000". - The cell reference is inside the quotes.
">G1"compares with the letters G1. Write">"&G1. - Hidden spaces. "Travel " with a trailing space isn't "Travel". Select the column and choose Data → Data cleanup → Trim whitespace.
- Numbers stored as text. Greater-than and less-than conditions match only real numbers, and SUMIF adds only real numbers. If imported numbers aren't counted, re-enter them as numbers.
- Semicolons instead of commas. If your spreadsheet's locale writes decimals with a comma, separate arguments with
;. Check Tools → Calculation & locale settings….
Related#
Frequently asked questions
What's the difference between SUMIF and SUMIFS?
SUMIF takes one condition and puts the range to add last. SUMIFS takes one or more conditions and puts the range to add first. SUMIFS works for a single condition too, so many people use it everywhere to avoid mixing up the order.
How do I count cells that match one value or another?
Add two COUNTIF formulas together, as in =COUNTIF(B2:B6, "Travel") + COUNTIF(B2:B6, "Meals"). COUNTIFS only counts rows that meet every condition at once.
Is COUNTIF case-sensitive?
No. "travel", "Travel" and "TRAVEL" all match the same cells. Extra spaces do count, so "Travel " with a trailing space doesn't match.
Why does COUNTIF with ">3000" miss some numbers?
Those cells probably hold numbers stored as text, which often happens with imported files. A greater-than or less-than condition only matches real numbers, and SUMIF only adds real numbers. Re-enter the values as numbers.
Did this answer your question?
One click, no account needed.
Still need help?
Our support team can take it from here.