Excel functions · Conditional math
COUNTIFS function in Excel
COUNTIFS counts the rows that meet every condition you give it, such as the number of North orders or of monitors sold for 320 or more. It takes pairs of a range and a condition, and every range must be the same size.
Last reviewed
Syntax
=COUNTIFS(criteria_range1, criteria1, [criteria_range2, criteria2], ...)- criteria_range1required
- The cells to test.
- criteria1required
- The condition, such as "North", ">=320" or a cell reference.
- criteria_range2, criteria2, ...optional
- More pairs, up to 127. A row is counted only when it meets all of them.
- Criteria are text: "South", ">=1000", "<>North", or ">"&G1 to compare with a cell. * and ? work as wildcards, and matching ignores case.
- To count non-empty cells use "<>" as the condition; to count blanks use "".
Which versions have COUNTIFS
Every current Excel version: Microsoft 365, Excel for the web, Excel 2024, 2021, 2019 and 2016, on Windows and Mac.
| Version | Has it |
|---|---|
| Microsoft 365 (Windows and Mac) | Yes |
| Excel for the web | Yes |
| Excel 2024 | Yes |
| Excel 2021 | Yes |
| Excel 2019 | Yes |
| Excel 2016 | Yes |
Google Sheets
Google Sheets has COUNTIFS with the same arguments and criteria syntax.
Examples
The examples use this sample sheet.
| Row | A | B | C | D | E |
|---|---|---|---|---|---|
| 1 | Order ID | Rep | Region | Product | Amount |
| 2 | 1001 | Ana | North | Laptop | 1200 |
| 3 | 1002 | Ben | South | Monitor | 300 |
| 4 | 1003 | Ana | North | Monitor | 350 |
| 5 | 1004 | Cara | East | Laptop | 1150 |
| 6 | 1005 | Ben | South | Laptop | 1250 |
| 7 | 1006 | Dev | West | Keyboard | 80 |
| 8 | 1007 | Cara | East | Monitor | 320 |
| 9 | 1008 | Ana | South | Keyboard | 90 |
1.Count one region
=COUNTIFS(C2:C9, "North")Result: 2
Orders 1001 and 1003 are in North.
2.Product and amount
=COUNTIFS(D2:D9, "Monitor", E2:E9, ">=320")Result: 2
Of the three monitor orders (300, 350, 320), two are 320 or more.
3.Not equal to
=COUNTIFS(B2:B9, "Ana", C2:C9, "<>North")Result: 1
Ana has three orders; only 1008 is outside North.
Common errors and fixes
| Error | Why it happens | Fix |
|---|---|---|
| #VALUE! | The criteria ranges are different sizes. | Make every range cover the same rows. |
| 0 when you expect a count | Extra spaces in the data or the criteria, or numbers stored as text. | Clean the data with TRIM and convert text numbers to numbers. |
Do it with GPTExcel
Skip writing COUNTIFS by hand
Upload your Excel or CSV file to Chat and ask in plain English. GPTExcel writes the formula for your file and your version of Excel or Google Sheets.
Count orders by region and product and show the result as a table.
Done. I used COUNTIFS on your sheet and checked the results against your data.
- Written for your platform and version
- Checked against your actual data
- Newest functions looked up in official docs
COUNTIFS questions
- What's the difference between COUNTIF and COUNTIFS?
- COUNTIF takes one range and one condition. COUNTIFS takes one or more pairs and counts rows that meet all of them, so it covers COUNTIF too.
- How do I count with OR conditions?
- Add two COUNTIFS together, for example =COUNTIFS(C2:C9, "East") + COUNTIFS(C2:C9, "West"), which returns 3 on the sample data.
Skip the formula hunt
Upload a spreadsheet and ask in plain English. Free plan, no credit card.
Start free