What Most People Miss About How to Use the AVERAGEIF Function in Excel

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

MethodStepsBest ForLimitations
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 rangeTRIM 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 formulaIf G1 is blank, AVERAGEIF treats it as "" — and matches *all empty cells*, not “no filter”.
AVERAGEIF ignoring #N/A or errorsWrap with IFERROR: =IFERROR(AVERAGEIF(A2:A12,"Sales",C2:C12),"-" )Reports where missing data shouldn’t break outputDoesn’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,000Threshold-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):

NameDeptSalaryStatusStart DateBonus
Sarah ChenSales$72,500Active2023-05-12$8,200
James RiveraSales$68,900Active2022-11-03$7,500
Priya MehtaMarketing$61,200Active2023-08-17$4,100
Diego LopezSales$75,400On Leave2024-01-09$9,300
Anya PetrovaHR$58,700Active2023-02-22$3,800
Kenji TanakaSales$69,800Active2023-12-05$7,900
Lena DuboisMarketing$63,100Active2024-02-14$4,400
Marcus BellSales$71,300Active2023-09-30$8,600
Fatima HassanFinance$66,400Active2023-07-11$5,200
Rajiv SinghSales$73,900Active2022-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

TaskFormulaShortcut / 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
Emily Watson

Emily Watson

Emily is an expert in workplace culture and team dynamics. Her articles help professionals navigate interpersonal challenges and build better coworker relationships.