Confident CellsExcel practice Start free

Gender pay gap calculation in Excel

Updated 2 December 2026 · 4 min read

The gender pay gap is the difference between men's and women's average hourly pay, as a percentage of men's pay: (men − women) ÷ men. If men average £18.00 an hour and women £16.20, the gap is 1.80 ÷ 18.00 = 10%. In Excel, =AVERAGEIF(B2:B9,"Male",C2:C9) gives the men's mean, and =(F2-F3)/F2 gives the gap. AVERAGEIF works in Excel 2007 and later, on Windows and Mac, and in Excel for the web; the median needs FILTER, in Excel 2021 and Microsoft 365.

This guide shows the spreadsheet steps. Who counts as a "full-pay relevant employee" and what counts as pay are set out in the government's gender pay gap guidance on GOV.UK: check it before you report.

Gender pay gap formulas at a glance

You wantFormulaNotes
Mean hourly pay for one group=AVERAGEIF(B2:B9,"Male",C2:C9)Sex in column B, hourly pay in C
The mean gap=(F2-F3)/F2Men's mean in F2, women's in F3; format as %
Median hourly pay for one group=MEDIAN(FILTER(C2:C9,B2:B9="Female"))Excel 2021 and Microsoft 365
Each person's place, lowest paid first=RANK.EQ(C2,$C$2:$C$9,1)For the pay quarters
Each person's pay quarter=ROUNDUP(D2/COUNT($C$2:$C$9)*4,0)1 is the lower quarter, 4 the upper
Share of women in a quarter=COUNTIFS(E2:E9,1,B2:B9,"Female")/COUNTIF(E2:E9,1)Format as %
Share of women given a bonus=COUNTIFS(B2:B9,"Female",C2:C9,">0")/COUNTIF(B2:B9,"Female")Bonuses in column C, for the 12 months before the snapshot date

Each one is worked through below.

The mean gap

AVERAGEIF averages only the rows that match: the column to check, what to look for, then the column to average (see AVERAGEIF and AVERAGEIFS).

=AVERAGEIF(B2:B9,"Male",C2:C9)
ABCDEF
1NameSexHourly payMean
2AmiraFemale£15.50Male£17.50
3BenMale£17.25Female£16.56
4CaraFemale£19.00
5DevMale£16.00Gap5.4%
6EwaFemale£14.75
7FinnMale£21.50
8GitaFemale£17.00
9HanaMale£15.25
F2 and F3 hold AVERAGEIF for each group. F5 holds =(F2-F3)/F2.

The four men's pay adds up to £70.00, so they average £70.00 ÷ 4 = £17.50. The four women's adds up to £66.25, an average of £16.56. The gap is (17.50 − 16.56) ÷ 17.50 = 5.4%. A positive gap means men are paid more on average; a negative one means women are. Format F5 as a percentage, and see percentages in Excel for why the % format multiplies by 100.

The median gap

Employers with 250 or more staff in England, Scotland and Wales publish the median gap too. The median is the middle value once the pay is in order, so one very high salary doesn't pull it up. With an even number of people, it's halfway between the middle two. The men's pay in order is £15.25, £16.00, £17.25 and £21.50, so their median is halfway between £16.00 and £17.25: £16.63. The women's is halfway between £15.50 and £17.00: £16.25.

There's no MEDIANIF, so give MEDIAN only one group's pay with FILTER (see UNIQUE and FILTER):

=MEDIAN(FILTER(C2:C9,B2:B9="Female"))
ABCDEF
1NameSexHourly payMedian
2AmiraFemale£15.50Male£16.63
3BenMale£17.25Female£16.25
4CaraFemale£19.00
5DevMale£16.00Gap2.3%
6EwaFemale£14.75
7FinnMale£21.50
8GitaFemale£17.00
9HanaMale£15.25
F2 holds =MEDIAN(FILTER(C2:C9,B2:B9="Male")) and F3 the same for Female. F5 holds =(F2-F3)/F2.

The median gap is (16.63 − 16.25) ÷ 16.63 = 2.3%, smaller than the mean gap, because Finn's £21.50 pulls the men's mean up more than their median.

Pay quarters

The published figures also split staff into four quarters with the same number of people in each, ranked by hourly pay, and give the share of men and women in each quarter. With 8 people, each quarter has 2. Rank everyone from the lowest paid, then divide the rank by the number of people and multiply by 4: Ewa is 1st of 8, and 1 ÷ 8 × 4 = 0.5, which rounds up to quarter 1. Cara is 7th, and 7 ÷ 8 × 4 = 3.5, which rounds up to quarter 4.

ABCDEFGH
1NameSexHourly payRankQuarterQuarterWomen
2AmiraFemale£15.5032150%
3BenMale£17.2563250%
4CaraFemale£19.0074350%
5DevMale£16.0042450%
6EwaFemale£14.7511
7FinnMale£21.5084
8GitaFemale£17.0053
9HanaMale£15.2521
D2 holds =RANK.EQ(C2,$C$2:$C$9,1) and E2 =ROUNDUP(D2/COUNT($C$2:$C$9)*4,0), both copied down. H2 holds =COUNTIFS($E$2:$E$9,G2,$B$2:$B$9,"Female")/COUNTIF($E$2:$E$9,G2), copied down.

Women are half of every quarter here, so the quarters show no gap even though the mean does. The guidance also says what to do when the number of staff doesn't divide by 4, and when people on the same pay fall either side of a quarter's edge: follow it for the real report. RANK has more on ranking.

Bonus pay

The report also gives the share of men and of women who were paid a bonus in the 12 months before the snapshot date, and the gap in their bonus pay. Here 2 of the 4 women had a bonus, so that's 2 ÷ 4 = 50%, and 3 of the 4 men did, so that's 75%:

=COUNTIFS(B2:B9,"Female",C2:C9,">0")/COUNTIF(B2:B9,"Female")
ABCDEF
1NameSexBonusHad a bonus
2AmiraFemale£0.00Female50%
3BenMale£500.00Male75%
4CaraFemale£400.00
5DevMale£250.00
6EwaFemale£0.00
7FinnMale£900.00
8GitaFemale£300.00
9HanaMale£0.00
F2 holds =COUNTIFS($B$2:$B$9,E2,$C$2:$C$9,">0")/COUNTIF($B$2:$B$9,E2), copied down. A bonus of £0 doesn't count.

COUNTIFS counts the women with a bonus above 0 and COUNTIF counts all the women (see COUNTIF). The bonus gap is worked out like the pay gap, but only over the people who had a bonus: AVERAGEIFS can average the bonuses for women with a bonus above 0.

Common mistakes

Dividing by women's pay

The gap is a percentage of men's pay. (17.50 − 16.56) ÷ 16.56 gives 5.7%, which is wrong.

Annual salaries for part-time staff

A part-time salary looks low even when the hourly rate is the same. Use hourly pay.

"male" matching "Female"

AVERAGEIF with "*male" would match both. Type the exact word, without wildcards.

Spaces and spellings in the Sex column

"Female " with a space on the end, or "F" on some rows, isn't counted as "Female", so those people drop out of the averages. Check the column with UNIQUE first: it should show just two values.

Try it now

Your turn

In F2, work out the mean hourly pay for the group named in E2, using AVERAGEIF. Your formula will be copied down to F3 for the other group, so use E2 rather than typing "Male", and lock the ranges.

ABCDEF
1NameSexHourly payMean pay
2AmiraFemale£15.50Male
3BenMale£17.25Female
4CaraFemale£19.00
5DevMale£16.00
6EwaFemale£14.75
7FinnMale£21.50
8GitaFemale£17.00
9HanaMale£15.25
10IvanMale£18.40
11JoFemale£16.10

Open this in Try a formula: the same sheet with the answer filled in, to change or share by link.

Part of Excel for HR: every lesson on the topic, with a project in Excel.

Where it works

AVERAGEIF, RANK.EQ, COUNTIFS and ROUNDUP work in Excel 2010 and later, on Windows and Mac, and in Excel for the web. FILTER needs Excel 2021, Microsoft 365 or Excel for the web. For other HR measures, see staff turnover rate.

Questions

How do you calculate the gender pay gap in Excel?

Work out the men's and the women's mean hourly pay with AVERAGEIF, such as =AVERAGEIF(B2:B9,"Male",C2:C9) in F2 and the same for Female in F3. Then =(F2-F3)/F2 gives the gap as a share of men's pay; format it as a percentage. Men on £17.50 and women on £16.56 give a gap of 5.4%.

How do I work out the median gender pay gap in Excel?

There's no MEDIANIF, so give MEDIAN one group's pay with FILTER: =MEDIAN(FILTER(C2:C9,B2:B9="Male")), and the same for Female. Then take the women's median from the men's and divide by the men's. FILTER needs Excel 2021 or Microsoft 365. The median isn't pulled up by one very high salary the way the mean is.

How are gender pay gap quarters worked out?

Rank everyone by hourly pay and split the list into four groups with the same number of people in each, then give the share of men and women in each group. In Excel, =RANK.EQ(C2,$C$2:$C$9,1) ranks from the lowest paid and =ROUNDUP(D2/COUNT($C$2:$C$9)*4,0) gives the quarter. The government guidance says how to handle numbers that don't divide by 4.

Is the gender pay gap a percentage of men's or women's pay?

Men's. The gap is men's average hourly pay minus women's, divided by men's: (17.50 − 16.56) ÷ 17.50 = 5.4%. Dividing by women's pay gives 5.7%, which isn't the published figure. A negative result means women are paid more on average. Figures can be given as whole percentages or to one decimal place.