Excel Supreme

Excel track · Exercise 19 of 86 Paid

COUNTIFS: several conditions

Count the rows that satisfy two conditions at once instead of filtering the table first.

Advanced

Ticket list by region, status and unit count

Read-only data · screen 1 of 2 · answer in D9

In D9, count the North orders that are still open with one function taking two conditions.

ABCD
1OrderRegionStatusUnits
2SO-1001NorthOpen5
3SO-1002SouthOpen3
4SO-1003NorthClosed4
5SO-1004EastOpen2
6SO-1005NorthOpen6
7SO-1006SouthClosed1
8SO-1007NorthOpen8
9North & open

Download this grid (.xlsx) Two tabs: the grid you see, and the answer.

D9

What it does

COUNTIFS counts the rows where every condition holds at the same time. Its arguments alternate range, condition, range, condition, and each range has to cover the same rows. COUNTIF does the same job for a single condition, which is why a second pair needs the other function.

Here B2:B8 must read North and C2:C8 must read Open, so rows 2, 6 and 8 qualify and the answer is 3. Asking COUNTIF for North alone returns 4, and the extra row is the closed North order in row 4.

The second screen swaps one text condition for a comparison, so D2:D8 has to come to more than 5 units. Row 2 holds exactly 5 and drops out, leaving 2. Comparisons travel inside quotes, and every condition you add can only narrow the count.

Syntax

=COUNTIFS(criteria_range1, criteria1, [criteria_range2, criteria2], ...)

Worked example

On Ticket list by region, status and unit count, =COUNTIFS(B2:B8,"North",C2:C8,"Open") returns 3.

=COUNTIFS(B2:B8,"North",C2:C8,"Open")

Common errors

Error codes for COUNTIFS with two condition pairs, text and comparison criteria
ErrorWhat it means and how to fix it
#VALUE!One criteria range covers a different number of rows from the others, so the conditions stop lining up.
Wrong totalTwo conditions that exclude each other, such as North and South on the same column, can never both hold for one row, and the count comes back as 0.
One conditionDropping the second pair counts every North order, which is 4 rather than 3.

At work

Counting open tickets in one region, and counting orders above a credit limit before dispatch.