Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

How to Average If in Excel: AVERAGEIF Guide

· 5 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

To average only the rows that meet a condition in Excel, use the AVERAGEIF function. The syntax is =AVERAGEIF(range, criteria, average_range), where range is the column you test, criteria is the condition (a number, text, or expression like ">100"), and average_range is the column of numbers to average. If you omit average_range, Excel averages the same cells it tested. That single formula replaces sorting, filtering, and manual selection, and it updates automatically when your data changes.

What You'll Need

  • Excel 2010 or later on Windows or Mac, or Excel for the web. AVERAGEIF is not available in Excel 2007 or earlier.
  • A table of data with one column to test (for example, a category or region column) and one column of numbers to average.
  • Consistent data types in the test column: numbers stored as numbers, text as text. Mixed types are the most common cause of wrong results.

Step-by-Step

  1. Lay out your data cleanly. Put the values you want to test in one column and the numbers you want to average in another. Leave no blank rows inside the data, because AVERAGEIF stops at the edge of the range you give it, and blank rows inside a selected range can skew what gets included.
  2. Click an empty cell where you want the result to appear.
  3. Type =AVERAGEIF( to start the formula. Excel will show a tooltip with the argument order: range, criteria, average_range.
  4. Select the test range. For example, if categories are in A2:A100, type A2:A100. Press the comma key to move to the next argument.
  5. Enter the criteria. This can be:
    • A text value in quotes: "North"
    • A number: 500
    • A comparison in quotes: ">100", "<=50", "<>0"
    • A cell reference: D1 (so you can change the condition without editing the formula)
    • A wildcard text match: "North*" matches anything starting with North
  6. Select the average range. This is the column of numbers to average, for example C2:C100. It should be the same size and shape as the test range. If you leave it out and close the bracket, Excel averages the test range itself, which is only correct when both are the same column.
  7. Close the bracket and press Enter. The result appears in the cell. The formula bar shows the full formula so you can check it.
  8. Copy the formula down or across if you need several conditions. Use absolute references (for example $A$2:$A$100) for the ranges so they do not shift when copied.

Worked example: Suppose column A holds regions and column C holds sales. To average sales for the North region, enter =AVERAGEIF(A2:A100,"North",C2:C100). To average only sales above 500, enter =AVERAGEIF(C2:C100,">500"). To average sales for North where the amount is above 500, use AVERAGEIFS instead: =AVERAGEIFS(C2:C100,A2:A100,"North",C2:C100,">500").

Common Mistakes

  • Forgetting quotes around comparisons. ">100" works; >100 without quotes causes an error or unexpected result.
  • Mismatched range sizes. If the test range is 99 rows and the average range is 100 rows, Excel may return a wrong average or an error. Keep them identical in size.
  • Numbers stored as text. A column that looks numeric but is left-aligned is text. AVERAGEIF ignores text values in the average range, so the result can be lower or zero. Convert with Text to Columns or VALUE().
  • Trailing spaces in text criteria. "North " does not match "North". Use TRIM on the source column or wildcards like "North*".
  • Using AVERAGEIF when you need multiple conditions. AVERAGEIF handles one condition. For two or more, use AVERAGEIFS, where each additional pair is a range and a criteria.
  • Including the header row. If the header text matches your criteria accidentally, or if the header is in the average range, results shift. Start ranges at the first data row.

Tips

  • Use a cell reference for the criteria so you can build a small summary table and change conditions without rewriting formulas.
  • Criteria are not case-sensitive: "north" matches "North".
  • Wildcards work in text criteria: ? matches one character, * matches any number of characters. To match a literal asterisk or question mark, put a tilde before it (~*).
  • If no rows match, AVERAGEIF returns #DIV/0!. Wrap it in IFERROR to show a blank or a message: =IFERROR(AVERAGEIF(...),"No matches").
  • For dynamic ranges that grow, convert your data to an Excel Table (Ctrl+T) and refer to structured references such as Table1[Region].
  • AVERAGEIF ignores blank cells and text in the average range, so the denominator is the count of numeric matches, not the count of all matches.

Troubleshooting

  • #DIV/0! error: No cells met the criteria, or all matching cells in the average range are blank or text. Check the criteria spelling and confirm the average range contains numbers.
  • #VALUE! error: A range argument is the wrong shape, or the criteria is malformed. Recheck quotes and commas.
  • Result looks too low: Some numbers are stored as text and are being skipped. Select the column, use Text to Columns with General format, or multiply by 1 in a helper column.
  • Result does not update: Calculation may be set to Manual. Go to Formulas > Calculation Options and choose Automatic.
  • Formula copied to other cells gives wrong answers: Relative references shifted. Lock the ranges with dollar signs.
  • Criteria with dates not matching: Dates must be real date values, not text. Use ">="&DATE(2024,1,1) style criteria or reference a date cell.

Frequently Asked Questions

What is the difference between AVERAGEIF and AVERAGEIFS?

AVERAGEIF applies one condition. AVERAGEIFS applies two or more, with the average range first: =AVERAGEIFS(avg_range, range1, criteria1, range2, criteria2).

Can AVERAGEIF average cells based on a cell color?

No. AVERAGEIF works on values, not formatting. You would need a helper column that flags colors manually or with VBA, then average on that flag.

Does AVERAGEIF include hidden rows?

Yes. AVERAGEIF includes hidden and filtered-out rows because it reads the range directly. To average only visible rows, use SUBTOTAL or AGGREGATE with a filter instead.

Why does AVERAGEIF return a different number than I calculated by hand?

Usually because some cells in the average range are text or blank and are excluded, or because the criteria matched more or fewer rows than expected. Check with COUNTIF using the same criteria to see how many rows matched.

Can I use AVERAGEIF across multiple sheets?

Yes, but the ranges must be on the same sheet as the formula or referenced with sheet names, for example Sheet2!A2:A100. 3D references across many sheets are not supported directly in AVERAGEIF.

What happens if the average range is omitted?

Excel averages the test range itself. This only gives the intended result when the values to average are in the same column as the criteria.