ExcelReady
CourseMock testsFunction guidesBlog
Start freeStart learning for free
ExcelReady

Be Excel-ready before day one. Hands-on practice in your browser, with instant feedback.

Learn

  • Course
  • Mock tests
  • Function guides
  • Blog

Test prep

  • Excel level test
  • Excel test practice
  • Free screening quiz
  • Certificate

Company

  • About
  • Editorial policy
  • Contact
  • Terms
  • Privacy

© 2026 ExcelReady. All rights reserved.

  1. Blog
  2. Conditional math
  3. How to Calculate an Average by Group in Excel

How to Calculate an Average by Group in Excel

By ExcelReady Team·Updated November 2, 2026·6 min read

The short answer

To calculate an average by group in Excel, list each group once, then use AVERAGEIF next to it: =AVERAGEIF($B$2:$B$9,F2,$D$2:$D$9) averages the scores in column D for the group named in F2. Fill it down for every group. Use AVERAGEIFS when each row must match two conditions, such as team and site, and IFERROR for groups with no rows.

Key takeaways

  • AVERAGEIF(group column, group name, numbers) gives the average for one group.
  • AVERAGEIFS puts the numbers first and accepts several conditions, such as team and site.
  • UNIQUE lists every group automatically in Excel 2021 and Microsoft 365.
  • A group with no rows returns #DIV/0!; wrap the formula in IFERROR.
  • Zeros are included in the average and blank cells are skipped.
On this page+
  1. The sample data
  2. How to average one group with AVERAGEIF
  3. How to build an average by group table
  4. List the groups automatically with UNIQUE
  5. Average by group with two conditions (AVERAGEIFS)
  6. Fix #DIV/0! for groups with no rows
  7. Zeros, blanks and text in the numbers
  8. Average by group with a PivotTable
  9. Practise it

To calculate an average by group in Excel, list each group once and put an AVERAGEIF formula next to it: =AVERAGEIF($B$2:$B$9,F2,$D$2:$D$9) returns the average for the group named in F2. Use AVERAGEIFS when you need a second condition. This guide is for anyone comparing teams, regions or products in a report or a job test, and it covers automatic group lists, empty groups and PivotTables too.

The sample data#

The examples use these training scores in A1:D9. Each employee belongs to one team and one site:

ABCD
1EmployeeTeamSiteScore
2AishaSalesLondon84
3BrunoSupportLeeds72
4ChloeSalesLeeds90
5DevSupportLondon65
6EmmaFinanceLondon88
7FaridSalesLondon78
8GraceSupportLeeds81
9HiroFinanceLeeds94

The overall average, =AVERAGE(D2:D9), is 81.5. The question is how each team compares with that.

How to average one group with AVERAGEIF#

AVERAGEIF averages the numbers in rows that match one condition. It has three arguments, in this order:

Excel formula
=AVERAGEIF(range, criteria, [average_range])
  • range is the column to check, here the Team column.
  • criteria is the group to match, such as "Sales".
  • average_range is the column of numbers to average.
Excel formula
=AVERAGEIF(B2:B9,"Sales",D2:D9)

The result is 84: (84 + 90 + 78) / 3. AVERAGEIF ignores capital letters, so "sales" works too. The AVERAGEIF, MAXIFS and MINIFS lesson practises this function alongside its cousins for the highest and lowest values.

How to build an average by group table#

A group table has one row per group and one formula per row. Point the criteria at a cell so the same formula works for every group:

  1. In F1 type Team and in G1 type Average.
  2. In F2:F4 type Sales, Support and Finance.
  3. In G2 type the formula below and fill it down (Windows: Ctrl+D; Mac: ⌘D).
Excel formula
=AVERAGEIF($B$2:$B$9,F2,$D$2:$D$9)
FG
1TeamAverage
2Sales84
3Support72.67
4Finance91

The $ signs lock both ranges, so only F2 changes as you fill down. Support's exact result is 72.666..., shown here with two decimals. To store a rounded value, wrap it: =ROUND(AVERAGEIF($B$2:$B$9,F2,$D$2:$D$9),1) returns 72.7.

This is the same layout as a sum by category or a count by category table. Put COUNTIF, SUMIF and AVERAGEIF side by side and you have a full summary per group.

List the groups automatically with UNIQUE#

In Excel 2021 or Microsoft 365, UNIQUE builds the list of groups for you. In F2, type:

Excel formula
=UNIQUE(B2:B9)

It spills Sales, Support and Finance into F2:F4, in the order they first appear. Then average every group with one formula in G2:

Excel formula
=AVERAGEIF(B2:B9,F2#,D2:D9)

The # refers to the whole spilled list, so when a new team appears in column B, both columns grow on their own. Use =SORT(UNIQUE(B2:B9)) for an A to Z list.

Average by group with two conditions (AVERAGEIFS)#

Use AVERAGEIFS when each row must match two or more conditions, such as team and site. Note the different order: the numbers to average come first, then pairs of ranges and criteria.

Excel formula
=AVERAGEIFS(D2:D9,B2:B9,"Sales",C2:C9,"London")

The result is 81: Aisha (84) and Farid (78). Chloe is in Sales but in Leeds, so she is left out. Support in Leeds gives 76.5 (72 and 81).

For a full grid, put teams down column F and sites across row 1, then use =AVERAGEIFS($D$2:$D$9,$B$2:$B$9,$F2,$C$2:$C$9,G$1) and fill right and down. The AVERAGEIFS function guide covers each argument. If you are unsure which of the two functions to use, the comparison of AVERAGEIF vs AVERAGEIFS explains the trade-offs, and the AVERAGEIFS guide has more condition examples.

Fix #DIV/0! for groups with no rows#

If no row matches a group, AVERAGEIF has nothing to divide by and returns #DIV/0!. For example, =AVERAGEIF(B2:B9,"Marketing",D2:D9) returns #DIV/0! because there is no Marketing team. Wrap the formula in IFERROR to show a message instead:

Excel formula
=IFERROR(AVERAGEIF($B$2:$B$9,F2,$D$2:$D$9),"No data")

Before you hide the error, check that it is really an empty group. A group name with an extra space, such as "Sales ", also matches nothing and gives the same error.

Zeros, blanks and text in the numbers#

AVERAGEIF and AVERAGEIFS treat empty cells and zeros differently, and that changes the result:

  • Blank cells in the number column are skipped. If Dev's score were empty, Support's average would be (72 + 81) / 2 = 76.5.
  • Zeros are included. If Dev's score were 0, Support's average would be (72 + 0 + 81) / 3 = 51.
  • Text, such as "Absent", is skipped like a blank.

If a 0 means "no score yet" rather than a real zero, exclude it with a second condition on the same column: =AVERAGEIFS(D2:D9,B2:B9,"Support",D2:D9,"<>0"). The guide to averaging without zeros covers this in detail.

Average by group with a PivotTable#

A PivotTable gives averages by group without formulas:

  1. Click a cell in the data and go to Insert > PivotTable, then click OK.
  2. Drag Team to Rows and Score to Values.
  3. The value shows Sum of Score. Click it, choose Value Field Settings, pick Average and click OK.

Drag Site to Columns for the team-by-site grid. Remember to right-click and Refresh after the data changes. Formulas update on their own and are what most tests check, so the pivot-style summary lesson teaches the formula version.

Practise it#

Try the exercise on this page: it averages one team at one site with AVERAGEIFS. Then practise AVERAGEIF, MAXIFS and MINIFS in a live spreadsheet, where you type each formula and it checks it instantly, and use the pivot-style summary lesson to build a full table of counts, totals and averages by group.

Try it yourself

This is a live spreadsheet. Type the formula in the green cell and press Enter.

What is the average score for the Sales team at the London site? Click G2 and use AVERAGEIFS with the scores in D2:D9, the Team column (B2:B9) and the Site column (C2:C9).

fx
ABCDEFGH
1
Employee
Team
Site
Score
2
Aisha
Sales
London
84
Sales, London
3
Bruno
Support
Leeds
72
4
Chloe
Sales
Leeds
90
5
Dev
Support
London
65
6
Emma
Finance
London
88
7
Farid
Sales
London
78
8
Grace
Support
Leeds
81
9
Hiro
Finance
Leeds
94
10
11
12

Tip: Start with the scores to average, D2:D9. Then add two pairs: B2:B9 with "Sales", and C2:C9 with "London".

Practise this in a lesson

LessonAVERAGEIF, MAXIFS and MINIFSFind the average, highest and lowest values that meet one or more conditions.LessonPivot-style summary with formulasBuild a summary table like a pivot table with formulas: a sorted UNIQUE list of categories, then SUMIFS and COUNTIFS filled down beside it.Function guideAVERAGEIFSAverage only the rows that meet several conditions with AVERAGEIFS. Text, number and blank criteria, common errors, and live practice.

Frequently asked questions

How do I average by group in Excel?

+

Type each group name once in a column, then use =AVERAGEIF($B$2:$B$9,F2,$D$2:$D$9) next to the first one and fill it down. B is the group column, F2 is the group name and D holds the numbers to average.

How do I average with two conditions in Excel?

+

Use AVERAGEIFS, which puts the numbers first: =AVERAGEIFS(D2:D9,B2:B9,"Sales",C2:C9,"London"). A row is included only when it meets every condition.

Why does AVERAGEIF return #DIV/0!?

+

No row matches the group, so Excel has nothing to divide by. Check the spelling and spaces in the group name, or wrap the formula in IFERROR to show a message such as No data.

Can a PivotTable show an average by group?

+

Yes. Put the group field in Rows and the number field in Values, then open Value Field Settings and choose Average instead of Sum.

Sources

  • AVERAGEIF function - Microsoft Support
  • AVERAGEIFS function - Microsoft Support
  • UNIQUE function - Microsoft Support

Written and checked by the ExcelReady Team. First published November 2, 2026. The practice exercise runs in the same formula engine as our lessons. Found a mistake? Read our editorial policy or email hello@excelready.app.

On this page

  1. The sample data
  2. How to average one group with AVERAGEIF
  3. How to build an average by group table
  4. List the groups automatically with UNIQUE
  5. Average by group with two conditions (AVERAGEIFS)
  6. Fix #DIV/0! for groups with no rows
  7. Zeros, blanks and text in the numbers
  8. Average by group with a PivotTable
  9. Practise it

Keep reading

Math· 6 min read

How to Average Without Zeros or Blanks in Excel

To average without zeros in Excel, use =AVERAGEIF(C2:C9,"<>0"). The criteria "<>0" means not equal to zero, so zero cells are left out of both the total and the count. Blank cells are already ignored by AVERAGE and AVERAGEIF. To add another condition, such as a region, use AVERAGEIFS.

Conditional math· 6 min read

How to Sum by Category in Excel

To sum by category in Excel, list each category once, then use SUMIF next to it: =SUMIF($A$2:$A$8,D2,$B$2:$B$8) adds the amounts in column B for the category named in D2. Fill it down for a full summary. In Excel 2021 or Microsoft 365, =UNIQUE(A2:A8) builds the category list for you, and a PivotTable does the same job without formulas.

Conditional math· 7 min read

How to Count by Category in Excel

To count by category in Excel, list each category once in a column, then use COUNTIF next to it: =COUNTIF($B$2:$B$9,F2) counts how many rows match the category in F2. Fill it down for the other categories. In Excel 2021 or Microsoft 365, =UNIQUE(B2:B9) builds the category list for you, and a PivotTable gives the same counts without formulas.

More on conditional math

  • AVERAGEIF and AVERAGEIFS in Excel
  • AVERAGEIFS in Excel: Averages With Several Conditions
  • Count Cells Above Average in Excel With COUNTIF
  • How to Count Cells With Text in Excel
  • Count and Sum Colored Cells in Excel
  • How to Count Duplicates in Excel
All conditional math articles →

Don't just read about Excel. Do it.

Practise real formulas in a live spreadsheet with instant feedback, right in your browser. Nothing to download.

Start learning for free