0Pricing
Excel Formulas Academy · Lesson

Averaging by Criteria With AVERAGEIF

Average only the values that meet a given test.

Averaging by Criteria With AVERAGEIF is a free Excel Formulas Academy lesson on CoddyKit — lesson 3 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Excel Formulas Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

Averaging Only What Matches

You have totaled with SUMIF and counted with COUNTIF. The third member of the family is AVERAGEIF, which finds the average of only the values that meet a condition.

Instead of averaging every sale, you can average just the East region sales, or just the scores above 50. It mixes a filter and a mean into one clean step.

The AVERAGEIF Pattern

AVERAGEIF uses the same three-part shape as SUMIF:

  • range the cells to test
  • criteria the condition
  • average_range the cells to average

It looks through range, finds matches, then averages the corresponding cells in average_range.

=AVERAGEIF(range, criteria, average_range)

A First Worked Example

With regions in A2:A10 and amounts in B2:B10, the average sale for the East region tests column A for East and averages the matching values in column B.

Behind the scenes it is doing a SUMIF divided by a COUNTIF, but AVERAGEIF wraps that into a single readable formula.

=AVERAGEIF(A2:A10, "East", B2:B10)

Same Range for Test and Average

If the column you test is also the column you want to average, you can leave off the third argument. To average only the scores in B2:B10 that are above 70:

Here column B is both tested and averaged. When you omit average_range, the spreadsheet uses range for both.

=AVERAGEIF(B2:B10, ">70")

Referencing the Criteria Cell

As with the other IF functions, store the condition in a cell for flexibility. If D1 holds a region name, point the criteria at D1.

Now one cell drives the average. Changing D1 from East to West recalculates instantly, which is ideal for a summary table or a dashboard selector.

=AVERAGEIF(A2:A10, D1, B2:B10)

Comparison Criteria

AVERAGEIF accepts operators inside quotes just like its siblings. To average only sales of at least 100:

  • ">=100" 100 or more
  • "<50" below 50
  • "<>0" excluding zeros

That last one is a favorite, because it averages while ignoring zero entries that would otherwise drag the mean down.

=AVERAGEIF(B2:B10, ">=100")

Operator Joined to a Cell

To use a threshold from a cell, glue the operator to it with an ampersand. If D1 holds a cutoff, average everything above it.

The & builds the condition text from ">" and the value in D1. This is the same join trick you used with SUMIF and COUNTIF.

=AVERAGEIF(B2:B10, ">"&D1)

Watch Out for the DIV/0 Error

AVERAGEIF has one trap the others do not. If no rows match, there is nothing to divide by and you get a #DIV/0! error.

For example, averaging a region that does not exist in the data returns this error. It is the spreadsheet telling you the filter matched zero cells, not that your formula is broken.

=AVERAGEIF(A2:A10, "North", B2:B10)

Guarding Against No Matches

Wrap the formula in IFERROR to show a friendly message instead of #DIV/0! when nothing matches.

Now an empty region shows the text No data rather than an alarming error. This keeps reports looking polished even when some categories are missing.

=IFERROR(AVERAGEIF(A2:A10, D1, B2:B10), "No data")

Blanks Are Skipped, Not Counted

AVERAGEIF only averages cells that contain numbers among the matches. Truly blank cells in the average_range are ignored, so they do not count as zero.

This matters: a missing value will not pull the average toward zero the way a literal 0 would. If you want zeros excluded too, add the criteria "<>0" on the value column.

=AVERAGEIF(B2:B10, "<>0")

A Deeper Example: Average per Category

Build a tidy summary: list each category in cells D2, D3, D4, then write one AVERAGEIF referencing the label cell and fill it down.

Each row now shows the average value for its own category, side by side with the SUMIF total and COUNTIF count from earlier lessons. Together they form a compact, fully formula-driven report.

=AVERAGEIF(A:A, D2, B:B)

Quick Check

Test your understanding of AVERAGEIF behavior.

Recap: AVERAGEIF

You can now average conditionally with AVERAGEIF. Key points:

  • The order is range, criteria, average_range; omit the last argument to average the test range itself.
  • It supports text, numbers, and operators like ">=100".
  • No matches produces a #DIV/0! error, so guard it with IFERROR.
  • Blank cells are skipped, not treated as zero.

Next you will match partial text using wildcards.

=AVERAGEIF(A2:A10, "East", B2:B10)

Frequently asked questions

Is the “Averaging by Criteria With AVERAGEIF” lesson free?

Yes — the full text of “Averaging by Criteria With AVERAGEIF” is free to read here on the web, and the Excel Formulas Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Excel Formulas Academy course, upgrade to CoddyKit PRO.

What will I learn in “Averaging by Criteria With AVERAGEIF”?

Average only the values that meet a given test. You practise Excel Formulas Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start Excel Formulas Academy?

No prior experience is required. Excel Formulas Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 3 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Averaging by Criteria With AVERAGEIF” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this Excel Formulas Academy lesson?

Yes. Every Excel Formulas Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. Summing by Criteria With SUMIF
  2. Counting by Criteria With COUNTIF
  3. Averaging by Criteria With AVERAGEIF
  4. Using Wildcards in Criteria
← Back to Excel Formulas Academy