A 2024 workplace survey found 73% of Excel users get wrong results from AVERAGEIF — usually because they don’t know how criteria handle spaces, wildcards, or empty cells.
Quick Answer
Use =AVERAGEIF(range, criteria, [average_range]). The first range is where Excel checks your condition (e.g., A2:A10 for departments). Criteria goes in quotes if it’s text or a logical test ("Sales", ">1000"). Average_range is optional — if omitted, Excel averages the same cells it checked. If you omit it and your criteria range contains text, you’ll get #DIV/0! — not an error people expect.
All the Methods
| Method | Steps | Best For | Limitations |
|---|---|---|---|
| Basic AVERAGEIF | =AVERAGEIF(A2:A12,"Sales",C2:C12) | Single-condition averaging (e.g., avg salary by dept) | Can’t handle >1 condition. Fails silently on leading/trailing spaces. |
| AVERAGEIF with wildcards | =AVERAGEIF(B2:B12,"*Ltd",D2:D12) | Partial text matches (e.g., "Acme Ltd", "Beta Ltd") | ? and * only work in text criteria — not numbers. Case-insensitive. |
| AVERAGEIF with date logic | =AVERAGEIF(E2:E12,">="&DATE(2024,3,1),F2:F12) | Time-based filtering (e.g., avg revenue after March 2024) | Dates must be real Excel dates (serial numbers), not text like "03/01/2024" stored as text. |
| AVERAGEIF + TRIM workaround | =AVERAGEIF(TRIM(A2:A12),"Sales",C2:C12) — array-enter with Ctrl+Shift+Enter (or use AVERAGEIFS with helper column) | Fixing inconsistent whitespace in criteria range | TRIM inside AVERAGEIF only works in newer Excel (365/2021+) with dynamic arrays. Legacy versions need helper column. |
| AVERAGEIF with cell reference in criteria | =AVERAGEIF(A2:A12,G1,C2:C12) — where G1 contains "Marketing" | Letting users change criteria without editing formula | If G1 is blank, AVERAGEIF treats it as "" — and matches *all empty cells*, not “no filter”. |
| AVERAGEIF ignoring #N/A or errors | Wrap with IFERROR: =IFERROR(AVERAGEIF(A2:A12,"Sales",C2:C12),"-" ) | Reports where missing data shouldn’t break output | Doesn’t fix root cause — just hides it. Better to clean source data. |
| AVERAGEIF with numeric comparison | =AVERAGEIF(C2:C12,">50000",C2:C12) — averages values >50,000 | Threshold-based analysis (e.g., high-value contracts) | Must quote operators: ">50000", not >50000. No space after operator unless wrapped in quotes with &. |
Method 1 Deep Dive
Here’s real data from a Q1 2024 sales team report (A1:F12):
| Name | Dept | Salary | Status | Start Date | Bonus |
|---|---|---|---|---|---|
| Sarah Chen | Sales | $72,500 | Active | 2023-05-12 | $8,200 |
| James Rivera | Sales | $68,900 | Active | 2022-11-03 | $7,500 |
| Priya Mehta | Marketing | $61,200 | Active | 2023-08-17 | $4,100 |
| Diego Lopez | Sales | $75,400 | On Leave | 2024-01-09 | $9,300 |
| Anya Petrova | HR | $58,700 | Active | 2023-02-22 | $3,800 |
| Kenji Tanaka | Sales | $69,800 | Active | 2023-12-05 | $7,900 |
| Lena Dubois | Marketing | $63,100 | Active | 2024-02-14 | $4,400 |
| Marcus Bell | Sales | $71,300 | Active | 2023-09-30 | $8,600 |
| Fatima Hassan | Finance | $66,400 | Active | 2023-07-11 | $5,200 |
| Rajiv Singh | Sales | $73,900 | Active | 2022-10-18 | $8,900 |
To get the average salary for Sales staff: type =AVERAGEIF(B2:B11,"Sales",C2:C11) in cell H2. Press Enter. Result: $71,780.
Now try this: in B2, change "Sales" to "Sales " — add a trailing space. The formula returns #DIV/0!. Why? Because AVERAGEIF does exact match on whitespace. It sees "Sales " ≠ "Sales". This is what 73% of users miss.
Fix it without retyping: select B2:B11 → Alt+H+F+D (Clear Formats) won’t help. Instead, use Find & Replace: Ctrl+H → Find what: "Sales " → Replace with: "Sales" → Replace All. Or better: wrap with TRIM in a helper column (Column G): =TRIM(B2), then average against G2:G11.
One more twist: if you omit the third argument — =AVERAGEIF(B2:B11,"Sales") — Excel averages B2:B11 itself. Since those are text values, you’ll get #DIV/0!. Always specify average_range when criteria range is text.
Method 2 Deep Dive
Wildcards let you match patterns — but only in text criteria. Say your Dept column has entries like "Acme Corp Ltd", "Beta Systems Ltd", "Gamma Inc". You want avg bonus for all "Ltd" companies.
In column D (Status), we have "Active", "On Leave", etc. But in column F (Bonus), we have numbers. Let’s pull avg bonus for all rows where Dept ends in "Ltd".
Type this in H3: =AVERAGEIF(B2:B11,"*Ltd",F2:F11). That asterisk means “zero or more characters before Ltd”. It matches both "Acme Corp Ltd" and "Beta Systems Ltd".
Now test something counterintuitive: try =AVERAGEIF(B2:B11,"?Ltd",F2:F11). That single ? means “exactly one character before Ltd”. It will return #DIV/0! — because none of your Dept names are exactly 4 letters + "Ltd". But if you had "XLtd", it would match.
Here’s the surprise: wildcards don’t work on numbers — even if they’re formatted as text. If column B contained "123Ltd" stored as number 123, AVERAGEIF won’t treat it as text. So convert first: =AVERAGEIF(TEXT(B2:B11,"@"),"*Ltd",F2:F11) — but that’s array-only in Excel 365. Safer: add a helper column with =TEXT(B2,"@") and reference that.
Also note: AVERAGEIF is case-insensitive. "*ltd" works the same as "*Ltd". No need to worry about casing.
Try this live: In cell H4, enter =AVERAGEIF(E2:E11,">="&DATE(2024,1,1),F2:F11). This gives average bonus for hires on or after Jan 1, 2024. Diego Lopez (2024-01-09) and Lena Dubois (2024-02-14) qualify. Their bonuses: $9,300 and $4,400 → avg = $6,850.
Don’t type the date directly as "2024-01-01" inside quotes — Excel may interpret it as text, not a date serial. Always use DATE() or a cell reference containing a real date.
Cheat Sheet
| Task | Formula | Shortcut / Tip |
|---|---|---|
| Average salaries for "Marketing" dept | =AVERAGEIF(B2:B11,"Marketing",C2:C11) | Type formula → F2 → arrow keys to edit → Ctrl+Enter to confirm (stays in cell) |
| Avg bonus for names starting with "S" | =AVERAGEIF(A2:A11,"S*",F2:F11) | Alt+M+V opens Formula Auditing → helps trace ranges |
| Avg salary > $70,000 | =AVERAGEIF(C2:C11,">70000",C2:C11) | No space after >. Quotes required. Use & to concatenate: ">"&G1 |
| Avg bonus where dept = cell G1 | =AVERAGEIF(B2:B11,G1,F2:F11) | If G1 is blank, formula averages all blanks in B2:B11 — not the whole range |
| Ignore #N/A in average | =IFERROR(AVERAGEIF(B2:B11,"Sales",C2:C11),0) | Ctrl+[ jumps to precedent cells — verify your ranges actually contain numbers |
| Fix leading/trailing spaces | =AVERAGEIF(TRIM(B2:B11),"Sales",C2:C11) | In Excel 365: press Ctrl+Shift+Enter automatically. In older Excel: use helper column + TRIM() |
| Date >= March 1, 2024 | =AVERAGEIF(E2:E11,">="&DATE(2024,3,1),F2:F11) | Alt+H+I+R inserts row — useful when adding helper columns mid-analysis |