Excel COUNTIFS examples: counting with multiple criteria, including between two values
How many items over £5 did Grace sell? On a charity shop's real sheet you'll see how COUNTIFS counts row by row, and you can write one yourself right away.
Christophe, founder of Lurndo
· 7 min read
COUNTIFS counts the rows that meet all your conditions at once. You give it a range and its criteria each time, as in =COUNTIFS(B2:B16,"Clothing",C2:C16,">5"). There's no range to count: the function counts rows. All the ranges must be the same size. To count between two values, use two conditions on one column, and for one thing or another, add two formulas together.

What does COUNTIFS do in Excel?
COUNTIFS counts the rows that meet all your conditions at once. Where COUNTIF asks one question, COUNTIFS asks as many as you need: is it clothing, and did it cost more than £5? =COUNTIFS(B2:B16,"Clothing",C2:C16,">5") returns 3, because three items of clothing cost more than £5. In a Dutch copy of Excel, the same function is called AANTALLEN.ALS.
Every example uses a week of sales at the Second Chance charity shop in Gloucester, the fourth client in our Excel course. If you'd rather learn the function step by step, follow the lesson on multiple conditions. If you're still counting with one condition, the COUNTIF examples show every kind of criteria. Here we look at what changes once a second condition comes in.
How do you write a COUNTIFS formula?
In pairs: a range, then the criteria that belong to that range. The first pair is required, and you can use up to 127 pairs (Microsoft). There's no separate range to count, like the sum range in SUMIFS: the function counts rows.
=COUNTIFS(criteria_range1,criteria1,[criteria_range2,criteria2],…)| Argument | What it is | Required? |
|---|---|---|
| criteria_range1 | The cells where you test the first condition | Yes |
| criteria1 | The first condition: text, a number, ">5" or a cell | Yes |
| criteria_range2, criteria2 | Another range with its condition, and so on | No |
With Dutch or Belgian regional settings you'd write =AANTALLEN.ALS(B2:B16;"Clothing";C2:C16;">5"). Only the function name and the separator change.
How do you count with two conditions?
Coordinator Yasmina at Second Chance wants to know how much pricier clothing left the shop. This is the whole sheet, with all fifteen sales. G2 holds a price limit of £10, which we'll refer to in a moment.
| Row | A: Item | B: Category | C: Price (£) | D: Day | E: Volunteer |
|---|---|---|---|---|---|
| 2 | Dress green | Clothing | 12 | Mon | Sophie |
| 3 | Book fiction | Books | 2 | Mon | Omar |
| 4 | Lamp | Household | 8 | Tue | Sophie |
| 5 | T-shirt S | Clothing | 3 | Tue | Grace |
| 6 | Dressing gown | Clothing | 6 | Wed | Omar |
| 7 | Puzzle | Toys | 4 | Wed | Grace |
| 8 | Book cooking | Books | 3 | Thu | Sophie |
| 9 | Radio | Electrical | 15 | Thu | Omar |
| 10 | T-shirt XL | Clothing | 4 | Fri | Sophie |
| 11 | Dress black | Clothing | 18 | Fri | Grace |
| 12 | What? Game | Toys | 5 | Sat | Omar |
| 13 | Vase | Household | 7 | Sat | Grace |
| 14 | T-shirt M | Clothing | 3 | Sat | Sophie |
| 15 | Bookend | Household | 9 | Sat | Omar |
| 16 | Kids' bike | Toys | 35 | Sat | Grace |
=COUNTIFS(B2:B16,"Clothing",C2:C16,">5")The formula returns 3. Excel goes down the rows and tests both conditions on each one. Clothing appears six times on the sheet, but only Dress green, Dressing gown and Dress black cost more than £5. The £15 radio drops out on its category, the T-shirts on their price. It doesn't matter that the conditions sit in different columns, because the function always looks at one row at a time.
Your turn. The exercise runs on Second Chance's real sheet, and you type the formula as you would in Excel.
Try it: Grace above £5
How many items over £5 did Grace sell? Work it out in I2 with COUNTIFS.
| A | B | C | D | E | F | G | H | I | J | |
|---|---|---|---|---|---|---|---|---|---|---|
| 1 | Item | Category | Price | Day | Volunteer | Limit | ||||
| 2 | Dress green | Clothing | £12.00 | Mon | Sophie | £10.00 | ||||
| 3 | Book fiction | Books | £2.00 | Mon | Omar | |||||
| 4 | Lamp | Household | £8.00 | Tue | Sophie | |||||
| 5 | T-shirt S | Clothing | £3.00 | Tue | Grace | |||||
| 6 | Dressing gown | Clothing | £6.00 | Wed | Omar | |||||
| 7 | Puzzle | Toys | £4.00 | Wed | Grace | |||||
| 8 | Book cooking | Books | £3.00 | Thu | Sophie | |||||
| 9 | Radio | Electrical | £15.00 | Thu | Omar | |||||
| 10 | T-shirt XL | Clothing | £4.00 | Fri | Sophie | |||||
| 11 | Dress black | Clothing | £18.00 | Fri | Grace | |||||
| 12 | What? Game | Toys | £5.00 | Sat | Omar | |||||
| 13 | Vase | Household | £7.00 | Sat | Grace | |||||
| 14 | T-shirt M | Clothing | £3.00 | Sat | Sophie | |||||
| 15 | Bookend | Household | £9.00 | Sat | Omar | |||||
| 16 | Kids' bike | Toys | £35.00 | Sat | Grace | |||||
| 17 |
Your formula ran in your own browser, on a real calculation engine. Then we run it again on a hidden version of the sheet, with other prices and volunteers. Anyone who just types 3 gets caught there.
How do you count between two values with COUNTIFS?
Use the same column twice, with a lower limit and an upper limit. This is the example most people look this function up for, because COUNTIF can't do it in one go. Excel tests both conditions on the same cell, and only what falls between the limits counts. Try it here.
Try it: the middle of the range
How many items cost £5 or more, and £10 or less? Work it out in I2.
| A | B | C | D | E | F | G | H | I | J | |
|---|---|---|---|---|---|---|---|---|---|---|
| 1 | Item | Category | Price | Day | Volunteer | Limit | ||||
| 2 | Dress green | Clothing | £12.00 | Mon | Sophie | £10.00 | ||||
| 3 | Book fiction | Books | £2.00 | Mon | Omar | |||||
| 4 | Lamp | Household | £8.00 | Tue | Sophie | |||||
| 5 | T-shirt S | Clothing | £3.00 | Tue | Grace | |||||
| 6 | Dressing gown | Clothing | £6.00 | Wed | Omar | |||||
| 7 | Puzzle | Toys | £4.00 | Wed | Grace | |||||
| 8 | Book cooking | Books | £3.00 | Thu | Sophie | |||||
| 9 | Radio | Electrical | £15.00 | Thu | Omar | |||||
| 10 | T-shirt XL | Clothing | £4.00 | Fri | Sophie | |||||
| 11 | Dress black | Clothing | £18.00 | Fri | Grace | |||||
| 12 | What? Game | Toys | £5.00 | Sat | Omar | |||||
| 13 | Vase | Household | £7.00 | Sat | Grace | |||||
| 14 | T-shirt M | Clothing | £3.00 | Sat | Sophie | |||||
| 15 | Bookend | Household | £9.00 | Sat | Omar | |||||
| 16 | Kids' bike | Toys | £35.00 | Sat | Grace | |||||
| 17 |
A date range works the same way, because a date is a number to Excel. With a real date in column D, =COUNTIFS(D2:D16,">="&DATE(2026,11,1),D2:D16,"<"&DATE(2026,12,1)) would count the sales of all of November. For how that handles times on the last day, see SUMIFS with a date range.
Which criteria can you combine?
All the ones you know from the lesson on criteria: text, numbers, comparisons, wildcards and references to a cell, in any mix. Microsoft lists the same wildcards as for COUNTIF (Microsoft). On Second Chance's sheet, that looks like this:
| Question | Formula | Result |
|---|---|---|
| Clothing on Saturday | =COUNTIFS(B2:B16,"Clothing",D2:D16,"Sat") | 1 |
| Sophie's sales above the limit in G2 | =COUNTIFS(E2:E16,"Sophie",C2:C16,">"&G2) | 1 |
| Saturday, but not Grace | =COUNTIFS(D2:D16,"Sat",E2:E16,"<>Grace") | 3 |
| T-shirts on Saturday | =COUNTIFS(A2:A16,"T-shirt*",D2:D16,"Sat") | 1 |
| Blank cells in column E | =COUNTIFS(E2:E16,"") | 0 |
The criteria with a cell are especially worth it. Put the limit in G2 and refer to it with ">"&G2, and Yasmina can change the limit without opening the formula. Only the operator goes in the quotation marks; the reference stays outside.
How do you build a summary by category and person?
With one formula you fill across and down, thanks to mixed references. Put the categories below each other in column K and the names side by side in row 1, then write this in L2:
=COUNTIFS($B$2:$B$16,$K2,$E$2:$E$16,L$1)Fill that formula right and down, and the ranges stay put, while $K2 follows the row and L$1 follows the column. That gives you a cross table:
| Sophie | Omar | Grace | |
|---|---|---|---|
| Clothing | 3 | 1 | 2 |
| Books | 1 | 1 | 0 |
| Household | 1 | 1 | 1 |
| Toys | 0 | 1 | 2 |
| Electrical | 0 | 1 | 0 |
Together that makes 15, as many as there are rows on the sheet. It's a handy check too: if the total is off, a category or name somewhere has a typo.
Can COUNTIFS work with OR?
Not with ordinary criteria: all the conditions must hold at once. That's why =COUNTIFS(B2:B16,"Clothing",B2:B16,"Books") returns 0. No single cell is clothing and books at the same time. For one thing or another, add two formulas: =COUNTIFS(B2:B16,"Clothing")+COUNTIFS(B2:B16,"Books") returns 8, six items of clothing and two books.
That addition works because a row has only one category. Ask for clothing or anything of Sophie's, and one row can meet both. Six items of clothing plus five sales by Sophie makes 11, while the real answer is 8: Sophie's three items of clothing are in the sum twice. So subtract them again, with a third formula that tests both conditions together.
Why isn't my COUNTIFS working?
Most mistakes give no message, just a count that's too low. First check whether your conditions can hold together, then work through this list.
You get 0 even though the rows exist
Spaces are the usual suspect. You can't see a trailing space in a cell, but "Clothing" won't find that cell any more. Microsoft names leading and trailing spaces as a cause of unexpected results (Microsoft). ">G2" gives 0 too, because Excel then looks for the letters G2 rather than the value in that cell.
The formula returns #VALUE!
Then the ranges usually aren't the same size. Each additional range must have as many rows and columns as the first (Microsoft). They don't have to sit next to each other, but they do have to be the same length. =COUNTIFS(B2:B16,"Clothing",E2:E15,"Sophie") stops on that single row of difference.
Criteria that refer directly to an empty cell are read as 0. With H1 empty, =COUNTIFS(C2:C16,H1) looks for prices of £0, and returns 0 without a warning.
A range is missing
Each criteria belongs to a range of its own. =COUNTIFS(E2:E16,"Omar",">5") doesn't work, because ">5" doesn't say which column to look in. Even when two conditions are about the same column, you write that column twice.
Which functions are like COUNTIFS?
COUNTIFS is the counter of a family. The other members do the same thing but work out something else, which is why they start with the range of numbers.
| Function | What it does | Example | Result |
|---|---|---|---|
| COUNTIFS | Counts rows | =COUNTIFS(B2:B16,"Clothing",E2:E16,"Sophie") | 3 items |
| SUMIFS | Adds up numbers | =SUMIFS(C2:C16,B2:B16,"Clothing",E2:E16,"Sophie") | £19 |
| AVERAGEIFS | Takes the average | =AVERAGEIFS(C2:C16,B2:B16,"Clothing",E2:E16,"Sophie") | £6.33 |
If you want amounts rather than items, read SUMIFS with examples. Averages with a condition are in AVERAGEIF and AVERAGEIFS, and every function with its Dutch name is on the Excel cheat sheet.
If you want to master counting with conditions, follow module 4 of the Excel course. You start with COUNTIF and build up to multiple conditions in six short lessons, and the first modules are free.
Frequently asked questions
What's the difference between COUNTIF and COUNTIFS?
COUNTIF counts with one condition, COUNTIFS with one or more. With two conditions, a row only counts when both hold. If you always use COUNTIFS, you've only got one function to remember. With one pair it does the same as COUNTIF, and you can add a condition later without rewriting anything.
How do you count with OR instead of AND?
Add two formulas together, one per condition. For clothing or books, write =COUNTIFS(B2:B16,"Clothing")+COUNTIFS(B2:B16,"Books"). If a row could meet both conditions, subtract the rows that meet both. Otherwise they count twice, and your total comes out too high without any warning from Excel.
How do you count cells between two values?
Use the same column twice, with a lower and an upper limit: =COUNTIFS(C2:C16,">=5",C2:C16,"<=10"). Watch the limits. With >= and <=, the values 5 and 10 count themselves; with > and < they don't. A date range works the same way with dates as the limits, because a date is a number to Excel.
Why does COUNTIFS return 0?
Usually no single row meets all the conditions at once. That happens when you ask for two different texts on the same column, because a cell can't be both. Also check for spaces in the cells, numbers stored as text, and a reference that ended up inside the quotation marks.
Can COUNTIFS count blank cells?
Yes, with the criteria "": =COUNTIFS(E2:E16,"") counts the empty cells, and "<>" counts what isn't empty. Don't confuse that with criteria that refer to an empty cell. According to Microsoft, COUNTIFS reads those as the value 0, so you'd be counting zeros instead of blanks.
Practise this in the course
Every lesson explains first and then lets you practise yourself, with a real spreadsheet in your browser.
- SUMIFSCounting and adding with conditions · Several conditions
- COUNTIFCounting and adding with conditions · Counting what matches
- CriteriaCounting and adding with conditions · Criteria with operators
Sources
- Microsoft Support, COUNTIFS function
- Microsoft Support, COUNTIF function
Christophe, founder of Lurndo
Christophe builds Lurndo from Belgium, with short, playful exercises for SQL, Excel, HTML & CSS and touch typing that show straight away what your answer does. On this blog, Christophe answers the questions people run into while learning, with sources you can check yourself.
Read next
AVERAGEIF and AVERAGEIFS examples: one condition or several, and why you get #DIV/0!Two functions with nearly the same name and their arguments in a different order. On a charity shop's real sheet you'll see when to use which, and where an average can lead you astray.Excel · · 7 min read
IFERROR and IFNA in Excel: catching errors without hiding the real onesA #DIV/0! or #N/A looks messy, but it's information too. On the sheets of a swimming pool and a bike courier, you'll see how to catch them neatly, and when to leave them alone.Excel · · 6 min read