Sub topic 9
Combining several conditions
This chapter assumes you can enter and copy formulas, understand relative and absolute references, and have used SUMIFS, COUNTIFS, and AVERAGEIFS with a single condition. Here you will add more conditions to one formula and learn how Excel combines them.
The examples use the sample sales layout. Headers are in row 1 and data runs from row 2 to row 100. Column A is Date, B is Region, C is Product, D is Amount, and E is Notes.
The rule: every pair must be true
Each IFS function accepts several pairs of a criteria range and a criteria. A row counts only when all* pairs are true for that row. This is AND logic.
Excel checks the pairs for the same row position. Row 2 of the first criteria range is combined with row 2 of every other range. The conditions never mix values from different rows.
Adding a second condition
Start with the single-condition version from earlier:
=SUMIFS(D2:D100, B2:B100, "West")Now add a second pair, a criteria range followed by its criteria, to the end:
=SUMIFS(D2:D100, B2:B100, "West", C2:C100, "Laptop")The sum range still comes first and appears only once. Every pair after it is a range followed by a criteria. With the sample rows, this formula returns 1200. Only the first data row is both West and Laptop.
COUNTIFS follows the same pattern, without a sum range:
=COUNTIFS(B2:B100, "West", C2:C100, "Laptop")This returns 1. AVERAGEIFS puts the average range first, like SUMIFS:
=AVERAGEIFS(D2:D100, B2:B100, "West", C2:C100, "Monitor")This returns 310, because only the 2025-02-02 row matches.
Mixing different kinds of conditions
Each pair can use a different style of criteria. You can combine exact text, an operator with a cell value, a wildcard, or a blank test in one formula. The earlier chapter's pattern for a minimum amount held in G1 fits here:
=SUMIFS(D2:D100, B2:B100, "West", D2:D100, ">=" & G1)If G1 contains 500, this returns 1200, because only that West row reaches 500. If G1 contains 300, it returns 1510 (1200 plus 310).
Notice that D2:D100 appears twice. It is the sum range and also a criteria range. That is allowed, because the roles are independent.
A blank test and a text test can work together as well:
=COUNTIFS(B2:B100, "West", E2:E100, "")This counts West rows with an empty Notes cell. With the sample rows the result is 2.
Two conditions on the same column
You can use the same range in more than one pair. This is how you set both ends of a range. Combined with dates, it gives a calendar month:
=SUMIFS(D2:D100, A2:A100, ">=" & DATE(2025,1,1), A2:A100, "<" & DATE(2025,2,1))The first pair keeps dates on or after 1 January. The second keeps dates before 1 February. Using "<" with the first day of the next month is safer than choosing the last day yourself. Dates that include a time of day on the 31st would be missed by a "<=" test on 31 January, and the "<" test avoids that. For the sample rows the result is 1500 (1200 plus 300).
You can add a third pair to narrow it further:
=SUMIFS(D2:D100, A2:A100, ">=" & DATE(2025,1,1), A2:A100, "<" & DATE(2025,2,1), B2:B100, "West")This returns 1200.
The range size rule
All ranges in one formula must have the same number of rows and columns. The range sizes decide how the rows are paired up. If they differ, Excel returns #VALUE!.
=SUMIFS(D2:D100, B2:B99, "West", C2:C100, "Laptop")This fails because B2:B99 has 98 cells and D2:D100 has 99. The ranges need not be next to each other or on the same sheet layout, but the shapes must match. Extending or trimming one range by accident is a common cause of this error, especially after inserting rows.
Contradictory conditions
Because every pair must be true, two exact tests on the same column can never both pass. This returns 0, not the sum for both regions:
=SUMIFS(D2:D100, B2:B100, "West", B2:B100, "East")No cell in column B is both "West" and "East". If you want either value, you need OR logic. That is a separate technique, covered in a later chapter. The usual form adds two SUMIFS results together:
=SUMIFS(D2:D100, B2:B100, "West") + SUMIFS(D2:D100, B2:B100, "East")Keep this distinction in mind when you read a request such as "West and East sales". In plain English "and" often means "or" for values in the same field.
Many conditions, and a limit
The functions accept up to 127 range and criteria pairs. In practice, long formulas become hard to read and audit. Two habits help:
- Put criteria in cells and refer to them, so you can see and change them without editing the formula.
- Order the pairs in the same sequence as your column headers, so the formula reads like the table.
A criteria cell that is empty is treated as a criterion of 0, not "no filter". If you build a formula that takes its criteria from cells, test what happens when one is left empty. A blank cell used as the criteria for the Notes column does not mean "any note". To match any text you would use "*", which matches any text value but not an empty cell or a number.
Common mistakes
| Symptom | Likely cause | Fix |
|---|---|---|
| `#VALUE!` | Ranges have different sizes | Make every range the same height and width |
| Result is 0 | Two exact tests on one column, or a typo in a criteria | Check the pairs for contradictions and spelling |
| Result is too small | Date end point excludes the last day | Use "<" with the first day of the next period |
| Wrong result after copying | Ranges shifted because they were not locked | Lock the ranges with `$` before copying |
| Argument order error | Sum range placed after a pair | Put the sum or average range first |
Practice
Exercise
Using the sample data, write a formula that totals Amount for rows where Region is "West", Product is "Monitor", and the Notes cell is empty. What value does it return for the four sample rows?
Show answer
=SUMIFS(D2:D100, B2:B100, "West", C2:C100, "Monitor", E2:E100, "") returns 310. Only the 2025-02-02 row is West, Monitor, and has no note. The East monitor row has a note and is the wrong region, so it is excluded.
Exercise
A colleague writes =COUNTIFS(B2:B100, "West", B2:B100, "East") to count West and East rows and gets 0. Why, and how do you fix it?
Show answer
Both pairs test column B, and no cell can equal both "West" and "East", so no row passes. To count either region, add two counts: =COUNTIFS(B2:B100, "West") + COUNTIFS(B2:B100, "East"). For the sample rows this returns 3.