Sub topic 2
Matching Text and Numbers Exactly
Assume you know how to enter and copy Excel formulas, use relative and absolute references, and work with basic SUM, COUNT, and AVERAGE. This chapter uses a sales table with headers in row 1:
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 GiftExact text and number criteria
Conditional aggregation applies a calculation only to rows that satisfy criteria. SUMIFS adds values, COUNTIFS counts rows, and AVERAGEIFS averages values.
=SUMIFS(D2:D100, B2:B100, "West")
=COUNTIFS(B2:B100, "West", C2:C100, "Laptop")
=AVERAGEIFS(D2:D100, B2:B100, "West")For SUMIFS and AVERAGEIFS, the first argument is the range to calculate. Each condition then uses a range and its criterion. COUNTIFS has only range-and-criterion pairs.
Text criteria use exact matching by default. Number criteria can also be written directly:
=SUMIFS(D2:D100, D2:D100, 300)Comparison operators in criteria
Put >, <, >=, <=, or <> inside a quoted criterion.
=SUMIFS(D2:D100, D2:D100, ">=500")
=COUNTIFS(D2:D100, "<>0")The <> operator means “not equal to.” Multiple criteria in one function are combined with AND logic.
flowchart TD
A[Each row] --> B{Region = West?}
B -- Yes --> C{Amount >= 500?}
C -- Yes --> D[Include row]
B -- No --> E[Exclude row]
C -- No --> ECriteria from cells
Join an operator to a cell reference with &. This lets someone change the threshold without editing the formula.
=SUMIFS(D2:D100, B2:B100, G1, D2:D100, ">=" & G2)Here, G1 contains a region such as West, and G2 contains a minimum amount such as 500.
Combining several conditions
Add another range-and-criterion pair for each condition:
=SUMIFS(D2:D100, B2:B100, "West", C2:C100, "Laptop")This adds Amount only where both Region is West and Product is Laptop. For OR logic across regions, add separate results:
=SUMIFS(D2:D100, B2:B100, "West") + SUMIFS(D2:D100, B2:B100, "East")Keeping ranges the same size
Every criteria range must cover the same rows as the calculation range. D2:D100 paired with B2:B100 is aligned. Mixing D2:D100 with B2:B50 can produce wrong results or #VALUE!.
Exercise
Write a formula that counts West rows with an Amount of at least 500.
Show answer
=COUNTIFS(B2:B100, "West", D2:D100, ">=500")