Excel AVERAGEIF function: the average by a condition
AVERAGEIF averages only the values that meet a condition. Group averages, excluding zeros, #DIV/0! and the zero-versus-blank trap — with examples.
AVERAGEIF averages the numbers only in rows that meet a condition. “What is the average score of group IT-21?”, “What is the average receipt at the Tashkent branch?”, “What are average daily sales, ignoring days off?”.
Plain AVERAGE takes the whole column. AVERAGEIF first picks rows by the condition, then averages only those. Logically it is SUMIF / COUNTIF, but in one function.
| A | B | C | D | E | F | G | |
|---|---|---|---|---|---|---|---|
| 1 | Student | Group | Score | Group | Average | ||
| 2 | Aziz | IT-21 | 86 | IT-21 | 85 | ||
| 3 | Dilnoza | IT-22 | 92 | ||||
| 4 | Javohir | IT-21 | 74 | ||||
| 5 | Kamola | IT-23 | 68 | ||||
| 6 | Sardor | IT-22 | 79 | ||||
| 7 | Malika | IT-21 | 95 | ||||
| 8 | Bekzod | IT-23 | 81 | ||||
| 9 |
Syntax
=СРЗНАЧЕСЛИ(range; criteria; [average_range])
- range — where the condition is tested:
B2:B8(groups). - criteria — the condition:
"IT-21",E2,">0",">="&F1,"IT*". Written as in COUNTIF. - average_range — the numbers to average:
C2:C8. Optional: if omitted,rangeitself is averaged.
Blank cells and text in average_range are ignored, but zeros are included. If no row matches — #DIV/0!.
Step by step: entering AVERAGEIF
1
Select F2 for the result.
2
Формулы → Вставить функцию → type AVERAGEIF in the search box (category Statistical) and click OK.
| A | B | C | D | E | F | G | |
|---|---|---|---|---|---|---|---|
| 1 | Student | Group | Score | Group | Average | ||
| 2 | Aziz | IT-21 | 86 | IT-21 | |||
| 3 | Dilnoza | IT-22 | 92 | ||||
| 4 | |||||||
| 5 |
3
Range — B2:B8, Criteria — E2 (the group name is in that cell), Average_range — C2:C8. Click OK.
| A | B | C | D | E | F | G | |
|---|---|---|---|---|---|---|---|
| 1 | Student | Group | Score | Group | Average | ||
| 2 | Aziz | IT-21 | 86 | IT-21 | |||
| 3 | Dilnoza | IT-22 | 92 | ||||
| 4 | |||||||
| 5 |
4
The result is 85. The formula: =СРЗНАЧЕСЛИ(B2:B8;E2;C2:C8). Type another group in E2 and the result updates by itself.
Example 1: a report for every group
List the groups in column E, lock the ranges with $ and fill the formula down. Averages often come with long decimals — round to one place with ROUND:
=ОКРУГЛ(СРЗНАЧЕСЛИ($B$2:$B$8;E2;$C$2:$C$8);1)
| A | B | C | D | E | F | G | |
|---|---|---|---|---|---|---|---|
| 1 | Student | Group | Score | Group | Average | ||
| 2 | Aziz | IT-21 | 86 | IT-21 | 85,0 | ||
| 3 | Dilnoza | IT-22 | 92 | IT-22 | 85,5 | ||
| 4 | Javohir | IT-21 | 74 | IT-23 | 74,5 | ||
| 5 | Kamola | IT-23 | 68 | All | 82,1 | ||
| 6 | Sardor | IT-22 | 79 | ||||
| 7 | Malika | IT-21 | 95 | ||||
| 8 | Bekzod | IT-23 | 81 | ||||
| 9 |
Example 2: an average without zeros, and days above target
The shop is closed on Sunday, so sales that day are 0. Plain AVERAGE counts that zero and artificially lowers “average daily sales”. No average_range is needed — the condition goes on the numbers themselves:
=СРЗНАЧЕСЛИ(B2:B8;"<>0")— the average without zeros.=СРЗНАЧЕСЛИ(B2:B8;">="&F1)— the average of days that hit the target in F1.
| A | B | C | D | E | F | G | |
|---|---|---|---|---|---|---|---|
| 1 | Day | Sales | Target | 5 000 000 | |||
| 2 | Monday | 4 200 000 | AVERAGE | 3 957 143 | |||
| 3 | Tuesday | 3 800 000 | No zeros | 4 616 667 | |||
| 4 | Wednesday | 4 500 000 | Above target | 5 650 000 | |||
| 5 | Thursday | 3 900 000 | |||||
| 6 | Friday | 5 100 000 | |||||
| 7 | Saturday | 6 200 000 | |||||
| 8 | Sunday | 0 | |||||
| 9 |
| A | B | C | D | E | F | G | |
|---|---|---|---|---|---|---|---|
| 1 | Student | Group | Score (0) | Score (blank) | Version | Average | |
| 2 | Aziz | IT-21 | 80 | 80 | With 0 | 57,0 | |
| 3 | Nodir | IT-21 | 0 | With blank | 85,5 | ||
| 4 | Dilnoza | IT-22 | 70 | 70 | No such group | — | |
| 5 | Malika | IT-21 | 91 | 91 | |||
| 6 | Sardor | IT-22 | 65 | 65 | |||
| 7 |
Pro level: distance from the group average
- Compare each row with its own group.
=C2-СРЗНАЧЕСЛИ($B$2:$B$8;B2;$C$2:$C$8)— how far a student is above or below their group’s average. Positive means stronger than the group, negative means behind. Add conditional formatting and the weak spots jump out. - Several conditions (group and subject) — AVERAGEIFS.
- A weighted average (by credit hours) can’t be done with AVERAGEIF — use
=СУММПРОИЗВ(Scores;Credits)/СУММ(Credits). - How many are above average:
=СЧЁТЕСЛИ(C2:C8;">"&СРЗНАЧ(C2:C8)).
| A | B | C | D | E | F | |
|---|---|---|---|---|---|---|
| 1 | Student | Group | Score | Group average | Difference | |
| 2 | Aziz | IT-21 | 86 | 85,0 | 1,0 | |
| 3 | Dilnoza | IT-22 | 92 | 85,5 | 6,5 | |
| 4 | Javohir | IT-21 | 74 | 85,0 | -11,0 | |
| 5 | Kamola | IT-23 | 68 | 74,5 | -6,5 | |
| 6 | Sardor | IT-22 | 79 | 85,5 | -6,5 | |
| 7 | Malika | IT-21 | 95 | 85,0 | 10,0 | |
| 8 | Bekzod | IT-23 | 81 | 74,5 | 6,5 | |
| 9 |
Try it in the simulator
Type =СРЗНАЧЕСЛИ($B$2:$B$8;E2;$C$2:$C$8) in F2 and fill it down to F4. Which group has the highest average score?
| A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | Student | Group | Score | Group | Average | |||||||||||||||||||
| 2 | Aziz | IT-21 | 86 | IT-21 | ||||||||||||||||||||
| 3 | Dilnoza | IT-22 | 92 | IT-22 | ||||||||||||||||||||
| 4 | Javohir | IT-21 | 74 | IT-23 | ||||||||||||||||||||
| 5 | Kamola | IT-23 | 68 | |||||||||||||||||||||
| 6 | Sardor | IT-22 | 79 | |||||||||||||||||||||
| 7 | Malika | IT-21 | 95 | |||||||||||||||||||||
| 8 | Bekzod | IT-23 | 81 | |||||||||||||||||||||
| 9 | ||||||||||||||||||||||||
| 10 | ||||||||||||||||||||||||
| 11 | ||||||||||||||||||||||||
| 12 |
Has ExcelLab been useful?
Support the project and help us release new lessons and exercises.