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.

COUNTIFS availability by Excel version
VersionHas it
Microsoft 365 (Windows and Mac)Yes
Excel for the webYes
Excel 2024Yes
Excel 2021Yes
Excel 2019Yes
Excel 2016Yes

Google Sheets

Google Sheets has COUNTIFS with the same arguments and criteria syntax.

Examples

The examples use this sample sheet.

Orders (A1:E9)
RowABCDE
1Order IDRepRegionProductAmount
21001AnaNorthLaptop1200
31002BenSouthMonitor300
41003AnaNorthMonitor350
51004CaraEastLaptop1150
61005BenSouthLaptop1250
71006DevWestKeyboard80
81007CaraEastMonitor320
91008AnaSouthKeyboard90
  1. 1.Count one region

    =COUNTIFS(C2:C9, "North")

    Result: 2

    Orders 1001 and 1003 are in North.

  2. 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. 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

COUNTIFS errors, causes and fixes
ErrorWhy it happensFix
#VALUE!The criteria ranges are different sizes.Make every range cover the same rows.
0 when you expect a countExtra 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.

your-file.xlsx

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.

your-file-updated.xlsxYour original stays unchanged
  • Written for your platform and version
  • Checked against your actual data
  • Newest functions looked up in official docs
Try it free Formula Generator

Free plan, no credit card.

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