Sub topic 3
Partial text matches with wildcards
This chapter assumes you can enter formulas, read range notation such as A2:A100, and write a basic COUNTIFS, SUMIFS, or AVERAGEIFS formula.
Partial text matches with wildcards
Wildcards are symbols that stand in for unknown characters. Three work in criteria:
*matches any number of characters, including none.?matches exactly one character.~escapes a wildcard, so~*matches a literal asterisk.
=SUMIFS(E2:E100, B2:B100, "Wid*")This sums Revenue for every product whose name starts with "Wid".
Counting and summing blank and non-blank cells
An empty string "" matches blank cells. The criterion "<>" matches non-blank cells.
=COUNTIFS(A2:A100, "West", B2:B100, "")
=COUNTIFS(A2:A100, "West", B2:B100, "<>")Handling no matches with IFERROR
AVERAGEIFS returns #DIV/0! when no row qualifies. Wrap it in IFERROR:
=IFERROR(AVERAGEIFS($E$2:$E$100, $A$2:$A$100, G2), "No matches")SUMIF, COUNTIF, and AVERAGEIF: how they differ
These single-condition versions take one criterion. SUMIF and AVERAGEIF place the value range last, while SUMIFS and AVERAGEIFS place it first.
| Function | Arguments | Result |
|---|---|---|
| COUNTIF | range, criterion | count |
| SUMIF | range, criterion, sum_range | total |
| AVERAGEIF | range, criterion, average_range | mean |
Getting OR logic
Criteria pairs always combine with AND. For OR, run one function per value and add the results:
=SUM(COUNTIFS(A2:A100, {"West","East"}))> Adding results double counts any row that matches more than one value. This is safe only when the values are mutually exclusive, as regions are.
Because the callout format does not allow block quotes, write it as a callout instead:
Putting it together: a summary table driven by criteria cells
Type region names in G2:G4. Use absolute references for the data columns so the formula can be filled down:
=SUMIFS($E$2:$E$100, $A$2:$A$100, G2)Fill the formula down into H2:H4, then add a count column with COUNTIFS. Changing a name in column G updates its row.
When to use something else
For complex text patterns, use REGEXMATCH inside FILTER. Use QUERY for SQL-style grouping, FILTER to list matching rows, and a pivot table for interactive summaries.
Exercise
Exercise
Write a formula that counts West rows whose Product cell is blank.
Show answer
=COUNTIFS(A2:A100, "West", B2:B100, "")