AVERAGEIF — Average by One Condition
The third and youngest member of the Legacy IFS trio. Point AVERAGEIF at a range, give it one condition, get back the mean of the matching values. Same shape as SUMIF — but with a nasty DIV/0 trap when zero rows match that neither SUMIF nor COUNTIF shares. Wrap in IFERROR and you're safe.
SUMIF/COUNTIF combined (Example 5). No _xlfn. prefix. Wildcards (* and ?) work the same as SUMIF and COUNTIF.#DIV/0! error — not zero, not blank. This is because "average = sum ÷ count" and when count is zero, you're dividing by zero. Unique to AVERAGEIF in the trio: SUMIF returns 0 on no matches, COUNTIF returns 0, but AVERAGEIF errors out.Standard defense: wrap in IFERROR. Full worked example in Example 4 below.
Syntax breakdown
AVERAGEIF takes up to three arguments — first two required, third optional. Same shape as SUMIF exactly.
| Argument | Type | What it does |
|---|---|---|
range |
REQUIRED | The range where the criteria will be evaluated. Text, numbers, or dates — AVERAGEIF walks each cell against the criteria. |
criteria |
REQUIRED | What to look for. Literal ("Emma Thompson", 5000), comparison in quotes (">=5000", "<>North"), cell reference (B2), or wildcard pattern ("Widget*"). |
average_range |
OPTIONAL | The range whose values get averaged when criteria match. Must be the same shape as range. If omitted, AVERAGEIF averages range itself. |
=AVERAGEIF(SalesAmount, ">=5000") with no third argument, AVERAGEIF uses the range as both test AND average. Result: the average of all values ≥ $5,000. Compact for numeric-threshold means.
Five working examples
Every example uses the 18-row Q1 2026 sales log from the workbook. Named ranges: SalesRep, SalesProduct, SalesRegion, SalesAmount, SalesDate.
01 Exact match — average sale by rep
The bread-and-butter AVERAGEIF use. "What's the average deal size for each rep?"
| Rep | Sales count | Total | AVERAGEIF result |
|---|---|---|---|
| Emma Thompson | 4 | $23,700 | $5,925.00 |
| David Kim | 4 | $23,200 | $5,800.00 |
| Michael Chen | 3 | $24,900 | $8,300.00 |
| Sofia Rodriguez | 3 | $12,700 | $4,233.33 |
| Aisha Patel | 2 | $12,300 | $6,150.00 |
| James Wilson | 2 | $11,600 | $5,800.00 |
Reading the answer: Michael Chen ($8,300 avg) closes the biggest deals on average despite fewer records. Aisha Patel ($6,150) has the second-highest per-deal size. Small counts can hide big performance — AVERAGEIF surfaces this instantly.
02 Wildcards — average across a product family
Average deal size for a WHOLE product line without listing each variant separately.
Reps whose name contains "Kim"
03 Comparison operators — with average_range OMITTED
Average all sales at or above $5,000. Since the range being tested IS the range being averaged, omit the third argument.
Below-threshold average
Exclusion filter
">=5000", not >=5000. Same rule as every *IF and *IFS function. Applies to >, <, >=, <=, <>, and =.
04 ⚠️ The DIV/0 trap and its IFERROR fix
The single most important defensive pattern for AVERAGEIF. Zero matches → DIV/0 error → broken dashboards. Wrap in IFERROR and problem solved.
The broken formula
The IFERROR fix
Alternative fallback values
Why AVERAGEIF errors but SUMIF and COUNTIF don't
| Function on zero matches | Math behind it | Result |
|---|---|---|
| SUMIF(...) | Sum of zero items = 0 | 0 (safe) |
| COUNTIF(...) | Count of zero items = 0 | 0 (safe) |
| AVERAGEIF(...) | 0 ÷ 0 (sum ÷ count) | #DIV/0! |
05 Cell reference criteria — dynamic averaging
Instead of hard-coding "Michael Chen", point the criteria at a cell. Change the cell → the average updates. Classic dashboard pattern.
Dynamic threshold
& concatenates the operator with the cell value at evaluation time.Combined with IFERROR — production-ready
AVERAGEIF on Excel 2003 — the SUMIF/COUNTIF trick
AVERAGEIF was added in Excel 2007. Before that, users combined SUMIF and COUNTIF manually:
AVERAGEIF(SalesRep, "Michael Chen", SalesAmount)Interactive playground
Try it Live AVERAGEIF demonstration
Mirrors live cells from the workbook. Edit the yellow input → the blue answer updates.
Download the workbook to try AVERAGEIF patterns across the full 18-row sales log.
The Legacy IFS trio — one condition, three metrics
Meet the family
Three sibling functions with the same single-condition shape. Each computes a different statistic on matching rows. This page is AVERAGEIF — the mean.
Consistency across the trio: same argument shape, same wildcard rules, same comparison-operator syntax. Only differences: SUMIF/COUNTIF are Excel 1.0+; AVERAGEIF is 2007+. And only AVERAGEIF has the DIV/0 trap on zero matches — the others gracefully return 0.
AVERAGEIF vs AVERAGEIFS — the same question, both ways
Same result. Different argument order.
Every AVERAGEIF query rewrites as AVERAGEIFS — just move average_range from the end to the beginning. Same pattern as SUMIF → SUMIFS. Six worked comparisons:
| Question | Legacy — AVERAGEIF | Modern — AVERAGEIFS |
|---|---|---|
| Michael Chen's average sale |
=AVERAGEIF(SalesRep, "Michael Chen", SalesAmount)
→ $8,300.00
|
=AVERAGEIFS(SalesAmount, SalesRep, "Michael Chen")
→ $8,300.00
|
| Widget A average |
=AVERAGEIF(SalesProduct, "Widget A", SalesAmount)
→ $2,560.00
|
=AVERAGEIFS(SalesAmount, SalesProduct, "Widget A")
→ $2,560.00
|
| Average sale in North |
=AVERAGEIF(SalesRegion, "North", SalesAmount)
→ $5,925.00
|
=AVERAGEIFS(SalesAmount, SalesRegion, "North")
→ $5,925.00
|
| All "Gadget" products avg |
=AVERAGEIF(SalesProduct, "Gadget*", SalesAmount)
→ $7,800.00
|
=AVERAGEIFS(SalesAmount, SalesProduct, "Gadget*")
→ $7,800.00
|
| Average sale ≥ $5,000 |
=AVERAGEIF(SalesAmount, ">=5000")
→ $8,944.44
|
=AVERAGEIFS(SalesAmount, SalesAmount, ">=5000")
→ $8,944.44
|
| Emma's Widget-only avg (2 conditions) |
AVERAGEIF cannot do this — only one condition
|
=AVERAGEIFS(SalesAmount, SalesRep, "Emma Thompson", SalesProduct, "Widget*")
→ $3,050.00
|
Bonus: DIV/0 behavior differs too. Legacy AVERAGEIF returns #DIV/0 on zero matches. AVERAGEIFS ALSO returns #DIV/0 — this trap survives migration. Both need IFERROR wrapping for defensive use.
Common errors and how to fix them
| Result | Why it happens | Broken → Fix |
|---|---|---|
| DIV/0 error | Zero rows match the criteria. AVERAGEIF's fatal flaw. | =AVERAGEIF(SalesRep, "Fake", SalesAmount) // no matches → DIV/0
=IFERROR(AVERAGEIF(SalesRep, "Fake", SalesAmount), "No matches") |
| DIV/0 (subtle) | Matches exist but average_range values are all blank or non-numeric. | Matching rows have blank amount cells → count is 0 for averaging
Same IFERROR pattern; or clean data with SUMIF/COUNTIF split |
| VALUE error | Wildcards used against a numeric range. | =AVERAGEIF(SalesAmount, "5*", SalesAmount) // wildcards on numbers
=AVERAGEIF(SalesAmount, ">=5000", SalesAmount) |
| Wrong average | range and average_range different shapes. | =AVERAGEIF(A2:A20, "X", B2:B15) // range mismatch
=AVERAGEIF(A2:A20, "X", B2:B20) // same size |
| Cell ref as text | Comparison operator jammed against cell reference without &. |
=AVERAGEIF(SalesAmount, ">=B2") // literal ">=B2"
=AVERAGEIF(SalesAmount, ">="&B2) |
| NAME error | Used on Excel 2003 — AVERAGEIF didn't exist yet. | =AVERAGEIF(range, crit, avg_range) // fails on Excel 2003
=SUMIF(range, crit, avg_range) / COUNTIF(range, crit) |
Related functions
Complementary functions
Excel version compatibility
AVERAGEIF was added in Excel 2007 — later than SUMIF and COUNTIF, which have been around since Excel 1.0. Nearly universal now, but with one important exception:
| Platform | Supports AVERAGEIF? | Notes |
|---|---|---|
| Excel 365 (Windows & Mac) | ✓ Yes | Full support |
| Excel 2021 / 2019 / 2016 / 2013 / 2010 / 2007 | ✓ Yes | Full support |
| Excel 2003 and earlier | ✗ No | Not available — use SUMIF/COUNTIF |
| Excel for the web | ✓ Yes | Full support |
| Excel on iPad & iPhone | ✓ Yes | Full support |
| Google Sheets | ✓ Yes | Same syntax |
| LibreOffice Calc | ✓ Yes | Full support |
| Apple Numbers | ✓ Yes | Full support |
=SUMIF(range, criteria, avg_range) / COUNTIF(range, criteria). Mathematically identical to AVERAGEIF. Bonus: gives you explicit control over the DIV/0 handling — if COUNTIF returns 0, you can catch it with IF before the division: =IF(COUNTIF(range, criteria)=0, "No matches", SUMIF(range, criteria, avg_range)/COUNTIF(range, criteria)).
How to write an AVERAGEIF from scratch
-
Identify the range you want to TEST
What column holds the values you're checking against a condition? That's the first argument.
-
Write the criteria
Exact text in quotes:
"Emma Thompson". Comparison operators inside quotes:">=5000". Cell references bare:B2. Cell reference with operator:">="&B2. -
Decide if you need a separate average_range
If the values you're testing ARE the values you want to average (like "average all amounts ≥ 5000"), omit average_range. Otherwise pass it as the third argument.
-
Wrap in IFERROR — always
AVERAGEIF is the only *IF that errors on zero matches. Make
=IFERROR(AVERAGEIF(...), "No matches")your default habit for anything user-facing. -
If you need a second condition — switch to AVERAGEIFS
AVERAGEIF is single-condition. For "Emma AND Widget A" or "January to March", migrate to AVERAGEIFS. Remember the argument-order flip: avg_range moves to the FIRST position.
Functions used with AVERAGEIF
Frequently asked questions
What's the difference between AVERAGEIF and AVERAGEIFS?
AVERAGEIF handles ONE condition; AVERAGEIFS handles multiple. Argument order is FLIPPED: AVERAGEIF puts average_range LAST (optional); AVERAGEIFS puts average_range FIRST (required). Same flip as SUMIF/SUMIFS — unlike COUNTIF/COUNTIFS which share the same order.
Why does AVERAGEIF return #DIV/0?
Because no rows matched the criteria, count is zero, and average = sum ÷ count is 0/0 — mathematically undefined. Unique to AVERAGEIF: SUMIF returns 0 on no matches (sum of nothing = 0) and COUNTIF returns 0. Wrap AVERAGEIF in IFERROR to guard: =IFERROR(AVERAGEIF(...), "No matches").
What happens if I omit the average_range?
AVERAGEIF averages the criteria range itself. Useful when the range being tested IS the range being averaged — like "average of all values ≥ 5000". Same trick works for SUMIF; COUNTIF has no equivalent since it doesn't sum anything.
Does AVERAGEIF ignore blank cells?
Yes. Matching rows with blank cells in average_range are excluded from both the sum AND the count. This prevents blanks from artificially pulling the average toward zero. Non-numeric (text) values in average_range are similarly skipped.
Can AVERAGEIF handle multiple conditions?
No. AVERAGEIF is single-condition only. For "rep = Emma AND product = Widget" or "date between X and Y", switch to AVERAGEIFS. The DIV/0 trap applies to both — always wrap either in IFERROR for user-facing formulas.
Do wildcards work in AVERAGEIF?
Yes — * matches any sequence of characters, ? matches exactly one. Only in TEXT criteria, not numeric ranges. Same rule as SUMIF and COUNTIF.
Does AVERAGEIF work in Excel 2003?
No — AVERAGEIF was added in Excel 2007. For 2003 compatibility, use =SUMIF(range, criteria, avg_range) / COUNTIF(range, criteria). Mathematically identical, and gives you explicit control over the divide-by-zero case.
Does AVERAGEIF work in Google Sheets?
Yes, identically. Same syntax across Google Sheets, LibreOffice, and Apple Numbers. DIV/0 behavior is the same too — the trap exists everywhere.
Is AVERAGEIF case-sensitive?
No. AVERAGEIF treats "Emma", "emma", and "EMMA" as the same. For case-sensitive conditional averaging, combine SUMPRODUCT with EXACT: =SUMPRODUCT(EXACT(range,"Emma")*avg_range) / SUMPRODUCT(--EXACT(range,"Emma")).
Why is my AVERAGEIF returning a wrong number?
Most common: numbers stored as text in average_range (fix with VALUE), or range and average_range having different shapes (they must be the same size). Also check for stray whitespace in criteria: "Emma " won't match "Emma".
Should I use AVERAGEIF or AVERAGEIFS?
Reasonable default: AVERAGEIFS, since it handles both single- and multi-condition cases with consistent syntax across the *IFS family. But AVERAGEIF is fine for one-condition cases and reads slightly more naturally. Either way, wrap in IFERROR — the DIV/0 trap survives migration.
Which templates use AVERAGEIF?
Templates showing per-category averages. Prominently: KPI Dashboard (average by metric type), Sales Dashboard (average deal size per rep), Employee Attendance (average hours per employee), Project Timeline (average task duration), Inventory Tracker (average stock levels), Timesheet (average hours per project), and Expense Report (average claim amount by category).
Templates that use AVERAGEIF
7 of our 10 templates use AVERAGEIF for per-category means:
Skip the syntax. Ask in plain English.
The Sheets & Cells AI Add-in writes AVERAGEIF, AVERAGEIFS, and every conditional-average pattern — right inside Excel. Type "average deal size by rep" and get the working formula, ready to paste. IFERROR wrapper included by default.
Try the AI Add-in →