Knowledge base / Excel

AVERAGEIF in Excel: criteria, empty cells, and zero

Five synthetic requests show how to select observations, reference a threshold cell, and distinguish zero from a missing measurement.

Kajo RudzińskiPublished Updated 5 min read

A machine selects one category of components before distributing them evenly

When I need an average handling time for one queue, I start by selecting observations. Only then do I calculate the mean. AVERAGEIF combines those steps: it checks one criterion and averages the corresponding values. The important question remains what one observation represents, and whether zero is an observed value or a replacement for missing data.

Syntax and workbook settings

Microsoft documents the function with this syntax:

=AVERAGEIF(range, criteria, [average_range])

The first range is checked against the criterion. The last argument supplies the numbers to average; if omitted, the first range is used. Square brackets in the syntax description mark an optional argument. Do not type them into the formula.

These examples use English function names, commas between arguments, and a decimal point. The Polish function is ŚREDNIA.JEŻELI. Separators depend on regional settings, as explained in Microsoft’s formula-error guide. If Excel rejects a pasted formula, check the function name and separator before changing the ranges.

One table and an average for a category

This is synthetic data. Put headers in A1:B1 and observations in A2:B6. Each row represents one request; time is a numeric number of minutes.

Row A: Queue B: Time
2 A 10
3 B 20
4 A 30
5 A 0
6 B 40
=AVERAGEIF(A2:A6, "A", B2:B6)

Rows 2, 4, and 5 qualify. Their values are 10, 30, and 0. The total is 40 across three observations, giving 40/3, approximately 13.33 minutes when displayed to two decimal places. Here, zero is an observed measurement and participates in the average.

Before writing a formula, I mark the intended rows on a small table like this. It separates a syntax issue from a different question. If you expect 20, you are probably omitting zero. Establish whether that exclusion has a substantive justification. Wanting a tidier result does not change the definition of an observation.

Numeric conditions and a threshold in a cell

For the average of positive times across all queues, one range is enough:

=AVERAGEIF(B2:B6, ">0")

The selected values are 10, 20, 30, and 40. Their mean is 100/4, or 25 minutes. The question has changed: this formula no longer restricts the result to queue A. That distinction is easy to miss when modifying an old calculation by inserting a condition in the wrong place.

Enter the number 20 in E1. To select times above it, join the operator to the reference:

=AVERAGEIF(B2:B6, ">"&E1)

This selects 30 and 40, giving 35. The string ">E1" would not join an operator to the contents of E1. Keeping the threshold separate makes scenarios easier to change, but E1 needs a clear label so another reader understands what the number means.

An empty cell, zero, and no result

The function documentation states that an empty cell in the average range is ignored. If you clear B5 in this example, queue A retains the numeric values 10 and 30. The result becomes 40/2, or 20 minutes. The denominator differs from the case with a numeric zero.

Do not type the word “empty” into B5 for this exercise. It needs to be a genuinely empty cell. In work data, establish what a missing measurement means and what a confirmed zero means. If both are replaced with zero during import, the average cannot recover the distinction afterwards.

For criterion "C", the table has no matching observations. The function returns #DIV/0!. I do not automatically replace every error with zero: an observed zero and no basis for calculation convey different information. If you add presentation handling, distinguish missing data from a source problem. General error-catching is explained in the IFERROR entry.

Measured values, a flat tile representing zero, and a separate empty space

Check the alignment of the ranges

Microsoft describes an important behaviour: the average range need not match the criterion range’s size. Excel can determine the cells used from its top-left corner and the first range’s dimensions. A shorter final argument is therefore an unreliable way to limit the number of observations.

I write both ranges explicitly as A2:A6 and B2:B6 here. I also inspect their starting rows: A2:A6 paired with B3:B7 could match a category to the wrong time. Equal row counts alone do not justify a result. The cells need to represent the same requests.

When you need another criterion

“Queue A and time above zero” requires two conditions at once. Move to AVERAGEIFS. Do not insert another condition where the average range belongs. The two functions use different argument orders.

Before placing a result in a report, add the unit and selected group. “Average time: 25” does not explain that the unit is minutes or that the selection includes positive observations from all queues. I also retain the number of measurements when discussing a finding. A number without its scope can answer a different question from the one the user intended.

An interpretation exercise

Using the original table, select queue B. You should identify 20 and 40, giving an average of 30 minutes. Then set E1 to 30 and reconsider ">"&E1. Only 40 remains; a value equal to the threshold does not satisfy “greater than”. Explain the difference between these questions in your own words before moving the formula into a larger workbook.

Key takeaways

Do an empty cell and zero produce the same mean?

No. An empty cell in the average range is ignored, while a numeric zero participates in the calculation.

How do I build a greater-than condition using E1?

Join the operator to the reference: ">"&E1. The string ">E1" does not read the cell contents.

How do I add another criterion?

Use AVERAGEIFS and note its different argument order.

AI was used in an automated way while working on this article. If you want to learn how to do it too, check out this project.

Kajo Rudziński

Newsletter KajoData

Let’s keep in touch.

I write about data analysis, learning and changing careers. My newsletter and the sign-up form are in Polish. If that works for you, I’d be glad to see you there.