Totals and counts by category with SUMIF and COUNTIF
Add up or count only the rows that match a word or a condition, such as all Design jobs or every invoice above 1,000.
FormulasIntermediate10 minExcel · Google Sheets
Example content. The numbers are fictional and made for learning.
Goal
Total the Design jobs in a mixed list, and count how many there are.
Why this is useful
Expense logs, sales lists, and time sheets mix categories in one list. SUMIF and COUNTIF give the total for each category without sorting or filtering by hand.
Example
| Row | A | B | C |
|---|---|---|---|
| 1 | Category | Item | Amount |
| 2 | Design | Logo | 1,200 |
| 3 | Flyers | 340 | |
| 4 | Design | Website mock-up | 2,100 |
| 5 | Ads | Social ads | 450 |
| 6 | Posters | 260 | |
| 7 | Design | Icons | 600 |
| 8 | Design total | 3,900.00=SUMIF(A2:A7,"Design",C2:C7) |
Steps
1. Keep one list
Put the category in one column and the amount in another. Spell each category the same way every time.
2. Total one category
Type =SUMIF(A2:A7,"Design",C2:C7). The first range is where to look, then the word to match, then the numbers to add. Swedish uses SUMMA.OM.
3. Count it
Type =COUNTIF(A2:A7,"Design") to see how many rows matched. Swedish uses ANTAL.OM.
4. Point at a cell instead of a word
Type the category in a cell, such as E2, and use =SUMIF(A2:A7,E2,C2:C7). Change E2 and the total follows. This is how summary tables are built.
5. Use a comparison
A condition can be a comparison in quotes: =COUNTIF(C2:C7,">1000") counts the amounts above 1,000.
Formulas by language
Cell names such as B2 stay the same. The function name and the character between arguments follow the spreadsheet language. The English line in each list is the reference form used on this site, not a universal spelling. When the decimal sign is a comma, arguments are usually separated with a semicolon, because the comma is already used in numbers.
Total of the Design rows.
English (United States)
Decimals look like 1.5. Arguments are separated with ,.
=SUMIF(A2:A7,"Design",C2:C7)Swedish (Sweden)
Decimals look like 1,5. Arguments are separated with ;.
=SUMMA.OM(A2:A7;"Design";C2:C7)German (Germany)
Decimals look like 1,5. Arguments are separated with ;.
=SUMMEWENN(A2:A7;"Design";C2:C7)French (France)
Decimals look like 1,5. Arguments are separated with ;.
=SOMME.SI(A2:A7;"Design";C2:C7)Spanish (Spain)
Decimals look like 1,5. Arguments are separated with ;.
=SUMAR.SI(A2:A7;"Design";C2:C7)Spanish (Mexico)
Decimals look like 1.5. Arguments are separated with ,.
=SUMAR.SI(A2:A7,"Design",C2:C7)Portuguese (Brazil)
Decimals look like 1,5. Arguments are separated with ;.
=SOMASE(A2:A7;"Design";C2:C7)Italian (Italy)
Decimals look like 1,5. Arguments are separated with ;.
=SOMMA.SE(A2:A7;"Design";C2:C7)Dutch (Netherlands)
Decimals look like 1,5. Arguments are separated with ;.
=SOM.ALS(A2:A7;"Design";C2:C7)
How many Design rows there are.
English (United States)
Decimals look like 1.5. Arguments are separated with ,.
=COUNTIF(A2:A7,"Design")Swedish (Sweden)
Decimals look like 1,5. Arguments are separated with ;.
=ANTAL.OM(A2:A7;"Design")German (Germany)
Decimals look like 1,5. Arguments are separated with ;.
=ZÄHLENWENN(A2:A7;"Design")French (France)
Decimals look like 1,5. Arguments are separated with ;.
=NB.SI(A2:A7;"Design")Spanish (Spain)
Decimals look like 1,5. Arguments are separated with ;.
=CONTAR.SI(A2:A7;"Design")Spanish (Mexico)
Decimals look like 1.5. Arguments are separated with ,.
=CONTAR.SI(A2:A7,"Design")Portuguese (Brazil)
Decimals look like 1,5. Arguments are separated with ;.
=CONT.SE(A2:A7;"Design")Italian (Italy)
Decimals look like 1,5. Arguments are separated with ;.
=CONTA.SE(A2:A7;"Design")Dutch (Netherlands)
Decimals look like 1,5. Arguments are separated with ;.
=AANTAL.ALS(A2:A7;"Design")
The average Design job.
English (United States)
Decimals look like 1.5. Arguments are separated with ,.
=AVERAGEIF(A2:A7,"Design",C2:C7)Swedish (Sweden)
Decimals look like 1,5. Arguments are separated with ;.
=MEDEL.OM(A2:A7;"Design";C2:C7)German (Germany)
Decimals look like 1,5. Arguments are separated with ;.
=MITTELWERTWENN(A2:A7;"Design";C2:C7)French (France)
Decimals look like 1,5. Arguments are separated with ;.
=MOYENNE.SI(A2:A7;"Design";C2:C7)Spanish (Spain)
Decimals look like 1,5. Arguments are separated with ;.
=PROMEDIO.SI(A2:A7;"Design";C2:C7)Spanish (Mexico)
Decimals look like 1.5. Arguments are separated with ,.
=PROMEDIO.SI(A2:A7,"Design",C2:C7)Portuguese (Brazil)
Decimals look like 1,5. Arguments are separated with ;.
=MÉDIASE(A2:A7;"Design";C2:C7)Italian (Italy)
Decimals look like 1,5. Arguments are separated with ;.
=MEDIA.SE(A2:A7;"Design";C2:C7)Dutch (Netherlands)
Decimals look like 1,5. Arguments are separated with ;.
=GEMIDDELDE.ALS(A2:A7;"Design";C2:C7)
How many amounts are above 1,000.
English (United States)
Decimals look like 1.5. Arguments are separated with ,.
=COUNTIF(C2:C7,">1000")Swedish (Sweden)
Decimals look like 1,5. Arguments are separated with ;.
=ANTAL.OM(C2:C7;">1000")German (Germany)
Decimals look like 1,5. Arguments are separated with ;.
=ZÄHLENWENN(C2:C7;">1000")French (France)
Decimals look like 1,5. Arguments are separated with ;.
=NB.SI(C2:C7;">1000")Spanish (Spain)
Decimals look like 1,5. Arguments are separated with ;.
=CONTAR.SI(C2:C7;">1000")Spanish (Mexico)
Decimals look like 1.5. Arguments are separated with ,.
=CONTAR.SI(C2:C7,">1000")Portuguese (Brazil)
Decimals look like 1,5. Arguments are separated with ;.
=CONT.SE(C2:C7;">1000")Italian (Italy)
Decimals look like 1,5. Arguments are separated with ;.
=CONTA.SE(C2:C7;">1000")Dutch (Netherlands)
Decimals look like 1,5. Arguments are separated with ;.
=AANTAL.ALS(C2:C7;">1000")
The same spoken language can use different separators in different countries. Spanish in Spain often uses a comma for decimals and a semicolon between arguments. Spanish in Mexico often uses a period and a comma. If a formula is rejected, check the spreadsheet locale.
Excel and Google Sheets
- The three functions take the same arguments in current Excel and Google Sheets.
- Matching is not case-sensitive: Design, design, and DESIGN are the same.
- For two or more conditions, use SUMIFS and COUNTIFS. Their argument order is different: the sum range comes first.
- Function names and the separator between arguments follow the spreadsheet language. Excel uses the language of your installation; Google Sheets uses the spreadsheet locale under File, Settings.
If something goes wrong
The total is 0.
The word does not match. Look for extra spaces or a different spelling in the list. A drop-down list for the category column prevents this.
The total is too large.
The two ranges are not the same size or do not start on the same row. A2:A7 must line up with C2:C7.
A comparison is ignored.
Put the comparison in quotes: ">1000", not >1000.