COUNTIF, SUMIF and Their -IFS Cousins
These functions count or add up only the rows that match a rule. They answer everyday questions like "How much did the North region sell?" We'll use this small sales table:
These are some of the most used functions in offices, because so many questions are "how many" or "how much" for a certain group: sales in the North region, orders above ₹500, absent days for one employee. Instead of filtering and adding by hand every time, one formula gives the answer and updates automatically when the data changes.
A B C D
1 Date Region Product Amount
2 01-11-26 North Pen 200
3 01-11-26 South Bag 900
4 02-11-26 North Bag 1800
5 03-11-26 East Pen 400
6 03-11-26 South Book 300One rule: COUNTIF and SUMIF
=COUNTIF(B2:B6, "North") → 2 (rows where Region is North)
=SUMIF(B2:B6, "North", D2:D6) → 2000 (add Amount where Region is North)
=COUNTIF(D2:D6, ">500") → 2 (amounts above 500)
=SUMIF(C2:C6, "B*", D2:D6) → 3000 (products starting with B: Bag, Bag, Book)SUMIF(range_to_check, rule, range_to_add). Rules can be text, numbers, comparisons in quotes (">500") and wildcards (* = any letters, ? = one letter).
Many rules: COUNTIFS, SUMIFS, AVERAGEIFS
Note the order: in SUMIFS the range to add comes first, then pairs of range + rule. All rules must be true.
=SUMIFS(D2:D6, B2:B6, "North", C2:C6, "Bag") → 1800
=COUNTIFS(B2:B6, "South", D2:D6, ">=300") → 2
=AVERAGEIFS(D2:D6, C2:C6, "Pen") → 300
=MAXIFS(D2:D6, B2:B6, "North") → 1800Rules from a cell
Put the rule in a cell so people can change it. Join a comparison and a cell with &:
F1: South F2: 500
=SUMIFS(D2:D6, B2:B6, F1) → 1200
=COUNTIFS(D2:D6, ">" & F2) → 2$D$2:$D$6) before copying a SUMIFS formula down a summary table, so the ranges don't move.- COUNTIF / SUMIF use one rule; COUNTIFS / SUMIFS many.
- In SUMIFS, the range to add comes first.
- Rules can be text, numbers, comparisons in quotes and wildcards.
- Lock ranges with $ before copying.
