What COUNTIFS does

COUNTIFS counts the rows that meet several conditions at once. “How many North orders were late?” has two, the region and the status, and =COUNTIFS(B2:B8,"North",C2:C8,"Late") counts the rows where both are true. COUNTIF tests one condition, and COUNTIFS can test up to 127.

You give it pairs: a range to test, then the condition for that range. Each pair adds one more test. The ranges sit side by side, row for row, so the second test on row 5 looks at the same order as the first. SUMIFS takes the same pairs when you want to add up the amounts on those rows.

It also answers “between” questions. Two conditions on the same column, at least 100 and at most 500, count the values that fall between them.

Syntax

=COUNTIFS(criteria_range1, criteria1, [criteria_range2, criteria2], ...)
Arguments in square brackets are optional; the rest are required.
criteria_range1Required
The first range to test, such as the region column B2:B8.
criteria1Required
The condition for that range: "North", ">=100", a number, or a cell such as F1. Comparisons go in quotation marks.
criteria_range2Optional, can repeat
The next range to test, such as the status column C2:C8. It must have the same number of rows and columns as the first range.
criteria2Optional, can repeat
The condition for that range. Add more pairs of range and condition as you need them, up to 127 pairs; a row is counted only when it meets every one.

Example: late orders from one region

Each order has a region in column B and a status in column C.

Orders 1001, 1004 and 1006 are both North and late. In B9, =COUNTIFS(B2:B8,"North",C2:C8,"Late") returns 3.

Order 1003 is from the North but on time, and order 1005 is late but from the East, so neither is counted.

Example: count the values between two limits

To count the orders worth from 100 to 500, test the same column twice:

120, 499, 500 and 230 are at least 100 and at most 500. In B9, =COUNTIFS(B2:B8,">=100",B2:B8,"<=500") returns 4.

>= and <= include the limits themselves, so the order for exactly 500 counts. Use > and < to leave the limits out.

Count one value or another (OR)

COUNTIFS joins its conditions with AND, so one formula can’t count the late orders from the North or the South. Write one COUNTIFS for each region and add them: =COUNTIFS(B2:B8,"North",C2:C8,"Late")+COUNTIFS(B2:B8,"South",C2:C8,"Late") returns 4 (3 + 1) on the orders above.

With a longer list, put the values in curly braces and wrap the formula in SUM: =SUM(COUNTIFS(B2:B8,{"North","South"},C2:C8,"Late")) gives the same 4.

Common mistakes

  • Every range in COUNTIFS must have the same shape. B2:B8 with C2:C9 gives #VALUE!.
  • =COUNTIFS(B2:B8,"North",B2:B8,"South") returns 0, because no cell says both. For one value or the other, add two counts together.
  • ">=100" works, but a limit kept in F1 has to be joined on: ">="&F1. Writing ">=F1" compares with the letters F1.
  • A typo in the text, or “Late ” with a trailing space in the data, makes the count 0 without any error. Check one condition at a time with COUNTIF.

Frequently asked questions

How many conditions can COUNTIFS take?

Up to 127 pairs of range and condition. A row is counted only when it meets every one of them.

How do I count between two dates with COUNTIFS?

Test the date column twice, with the first and last day in cells: =COUNTIFS(A2:A50,">="&F1,A2:A50,"<="&F2) counts the rows dated from F1 to F2, both included.

How do I use not equal to in COUNTIFS?

Put <> in front of the value: =COUNTIFS(B2:B8,"North",C2:C8,"<>Late") counts the North orders that weren’t late. To leave out the value in a cell, join it on with "<>"&F1.

How do I count non-blank cells with COUNTIFS?

Use "<>" as the condition: =COUNTIFS(B2:B8,"North",D2:D8,"<>") counts the North rows that have something in column D. Use "" to count the rows where it’s empty.

Does COUNTIFS work with wildcards?

Yes, in text conditions: "*urgent*" matches any cell that contains “urgent”, in any capitals.