Sub topic 9
Combining several conditions
This chapter assumes you can enter and copy formulas, know relative and absolute references, and have written a single-condition SUMIFS, COUNTIFS, or AVERAGEIFS. The examples use the sales layout from earlier chapters: Date in column A, Region in B, Product in C, Amount in D, and Notes in E, with data in rows 2 to 100.
AND logic in one formula
All three functions accept more than one range and criteria pair. A row counts only if every pair is true. This is AND logic.
=COUNTIFS(B2:B100, "West", C2:C100, "Laptop")This counts rows where Region is West and Product is Laptop. A West monitor row fails the second test, so it is skipped.
Adding pairs to SUMIFS and AVERAGEIFS
In SUMIFS and AVERAGEIFS, the range to add or average comes first. The pairs follow in any order.
=SUMIFS(D2:D100, B2:B100, "West", C2:C100, "Monitor")=AVERAGEIFS(D2:D100, B2:B100, "West", C2:C100, "Laptop")You can add as many pairs as you need, up to 127. COUNTIFS has no sum range, so its first argument is already a criteria range.
Using the same column twice
A column can appear in more than one pair. This is how you set a lower and upper limit on one field. The next formula adds West amounts that are at least the value in G1.
=SUMIFS(D2:D100, B2:B100, "West", D2:D100, ">=" & G1)Here Amount is both the range being added and a column being tested. That is allowed.
Common mistakes
- Range sizes differ. Every range must have the same number of rows and columns. If one is
B2:B100and another isC2:C99, the result is #VALUE!. - Expecting OR. Putting "West" and "East" in two pairs for the same column returns 0, because no row is both. Combining values with OR is covered in a later chapter.
- Missing quotes around operators. Write
">=" & G1, not>=G1. - A missing partner. Every range needs a criterion. An odd number of arguments after the sum range causes an error.
Summary table
| Function | First argument | Then |
|---|---|---|
| SUMIFS | Range to add | Range and criteria pairs |
| AVERAGEIFS | Range to average | Range and criteria pairs |
| COUNTIFS | First criteria range | Its criterion, then more pairs |
Exercise
Write a formula that totals Amount for rows where Region is West, Product is Monitor, and Amount is at least 300. What does it return for the sample rows?
Show answer
=SUMIFS(D2:D100, B2:B100, "West", C2:C100, "Monitor", D2:D100, ">=300"). Only the 2025-02-02 row (West, Monitor, 310) matches all three conditions, so it returns 310.