Sub topic 1
Why conditional totals matter
A plain SUM, COUNT, or AVERAGE treats every cell in a range the same way. Real questions rarely work like that. You usually want the total for one region, the number of orders above a threshold, or the average for one product in one quarter. This chapter explains what conditional aggregation is, why the *IFS functions are the standard way to do it in Excel, and what the rest of the tutorial covers.
Prerequisites
This chapter assumes you can already do the following:
- Enter a formula in a cell and copy it to other cells.
- Tell relative references (
D2) from absolute references ($D$2). - Use SUM, COUNT, and AVERAGE on a range.
- Work with data laid out in rows and columns, with a header in row 1.
If the reference types are unfamiliar, review them first. Later chapters rely on them when formulas are copied across summary tables.
What conditional aggregation means
Aggregation is reducing many values to one number: a total, a count, or a mean. Conditional aggregation does the same thing but only for the rows that meet conditions you specify. Each condition is a test applied to one column, such as "Region equals West" or "Amount is at least 500".
Excel provides three functions for this:
| Function | Question it answers | Result |
|---|---|---|
| SUMIFS | What is the total of this column for matching rows? | A sum |
| COUNTIFS | How many rows match? | A count |
| AVERAGEIFS | What is the mean of this column for matching rows? | An average |
All three accept several conditions at once. A row is included only when every condition is true for that row.
The sample data
Every example in this tutorial uses one small sales table. Headers are in row 1, and data runs from row 2 down to row 100. Only the first few rows are shown here.
A: Date B: Region C: Product D: Amount E: Notes
2025-01-05 West Laptop 1200
2025-01-09 East Monitor 300 Backorder
2025-02-02 West Monitor 310
2025-02-14 North Laptop 1150 GiftColumn D holds the numbers to add or average. Columns A, B, C, and E hold the values that conditions test. Keep this layout in mind, because the formulas refer to these column letters.
A first conditional total
Suppose you need the total Amount for the West region. Reading the rows shown above, that is 1200 + 310 = 1510.
=SUMIFS(D2:D100, B2:B100, "West")The formula has two parts:
- The first argument,
D2:D100, is the range to add. - The next two arguments are a pair: a range to test (
B2:B100) and a criterion ("West").
Excel looks at each row. If column B in that row equals West, it adds the value from column D in the same row. Rows for other regions are skipped.
Counting and averaging
The same pattern covers counting and averaging. COUNTIFS has no range to add, because it only counts rows. It takes one or more range and criterion pairs.
=COUNTIFS(B2:B100, "West", C2:C100, "Laptop")This counts rows where Region is West and Product is Laptop. Both conditions must be true for a row to be counted.
AVERAGEIFS puts the range to average first, as SUMIFS does.
=AVERAGEIFS(D2:D100, B2:B100, "West")This returns the mean Amount for West rows. In the four sample rows, that would be (1200 + 310) / 2 = 755.
How the pieces fit together
The three functions differ only in what they do with the rows that pass the tests. The diagram shows the shared flow.
This is the working model for the whole tutorial. Whatever the criteria look like, the function checks each row, keeps the rows that pass, and then adds, counts, or averages them.
Why not filter and read the status bar?
You can get the same numbers by filtering the table and reading the total in the status bar, or by copying matches to a new sheet. That works once. It has costs:
- The result is not stored in a cell, so it cannot feed other formulas or a report.
- It does not update when the data changes, unless you repeat the steps.
- Each different question needs another round of filtering.
A formula stays in the cell, recalculates when the data changes, and can read its conditions from other cells. That last point is what lets you build a whole summary table from one formula, which a later chapter covers.
What the *IFS functions do not do
Knowing the limits early prevents confusion later.
- Conditions inside one function are combined with AND. A row must pass all of them. OR logic takes extra work, covered in its own chapter.
- Each condition tests one range against one criterion. A criterion cannot be an arbitrary formula over the row, such as "Amount is more than twice the average".
- The ranges must be the same size. A mismatch returns
#VALUE!. - AVERAGEIFS returns
#DIV/0!when no rows match, because there is nothing to average.
For richer logic, PivotTables and SUMPRODUCT exist. They are covered in the final chapter, after you know where the *IFS functions stop being enough.
Where the older functions fit
Excel also has SUMIF, COUNTIF, and AVERAGEIF, which allow only one condition. The *IFS versions handle one condition too, so you can use them everywhere and not switch between families.
There is one difference to remember. In SUMIF, the range to add comes last. In SUMIFS, it comes first. Mixing up the order is a common mistake when people move between the two.
What the rest of the tutorial covers
The remaining chapters build on this one in order:
- How the arguments are structured, then each function in detail.
- Writing criteria: exact text and numbers, comparison operators, wildcards, dates, and blanks.
- Driving criteria from cells, combining conditions, and keeping ranges aligned.
- Handling
#DIV/0!, OR logic, and summary tables built with mixed references and Excel tables. - Troubleshooting wrong totals, and choosing other tools when the
*IFSfunctions are not the best fit.
Exercises
Exercise
Using the sample columns (Region in B, Product in C, Amount in D, rows 2 to 100), write a formula that counts the rows where Region is East and Product is Monitor.
Show answer
=COUNTIFS(B2:B100, "East", C2:C100, "Monitor"). COUNTIFS takes only range and criterion pairs, and a row is counted only when both conditions are true. In the four sample rows the result is 1.
Exercise
A colleague writes =SUMIFS(B2:B100, "West", D2:D100) to total West sales. Explain what is wrong and give the corrected formula.
Show answer
The arguments are in the wrong order. SUMIFS takes the range to add first, then range and criterion pairs. Here "West" sits where a range is expected, and the pair is split. The corrected formula is =SUMIFS(D2:D100, B2:B100, "West").
Exercise
Why does =AVERAGEIFS(D2:D100, B2:B100, "South") return #DIV/0! with the sample data, and what does that tell you about the data?
Show answer
No row has Region equal to South, so there are no values to average and Excel divides by zero. The error means no rows matched the condition. Either South is absent from the data or the criterion does not match how the value is written, for example because of a spelling difference.