Tabellab
Data, tech, science & health

Mann-Whitney U test in Excel, step by step

The Mann-Whitney U test, also called the Wilcoxon rank-sum test, compares two independent groups without assuming that the data is normally distributed. Excel has no built-in function for it, but a handful of formulas do the job: rank all values together, add up the ranks per group, turn each rank sum into U, and convert the smaller U into a z-score and a p-value. In the example below, 9 deliveries with a new routing app (median 31 minutes) are compared with 8 deliveries with the old app (median 39.5 minutes): U = 14.5, z = −2.069 and a two-sided p-value of 0.0386, so the difference is significant at the 5% level.

Updated 21 Oct 2026 6 min read By Tabellab team

When to use the Mann-Whitney U test

Use it to compare two independent groups, with different customers, orders or patients in each, when a two-sample t-test is a poor fit: the data is skewed, has outliers, is measured on an ordinal scale such as ratings, or the groups are small. Delivery times are a typical case. Most are close together, but a few late orders stretch the right tail and pull the mean up. Ranks ignore how extreme a value is, so the 61-minute delivery counts no more than any other slowest value would.

For paired data, such as the same couriers before and after a training, use the Wilcoxon signed-rank test instead. For three or more groups, use Kruskal-Wallis.

Worked example: delivery times with the old and the new routing app

Rows 2 to 18 are the data, one delivery per row, ranked together in column C. Rows 19 to 29 calculate U, z and the p-value. The data is fictional.

Worked example: delivery times with the old and the new routing app
ABC
1AppMinutesRank (all 17)
2Old348.0
3Old4113.0
4Old293.5
5Old5216.0
6Old3811.0
7Old4515.0
8Old3610.0
9Old6117.0
10New272.0
11New316.0
12New293.5
13New337.0
14New4012.0
15New261.0
16New359.0
17New305.0
18New4414.0
19OldNew
20Group size n89
21Median minutes39.531.0
22Rank sum R93.559.5
23U = R − n(n + 1)/257.514.5
24Check: U₁ + U₂ and n₁ × n₂72.072
25U (the smaller one)14.5
26Mean of U under H036.0
27SD of U10.392
28z-2.069
29Two-sided p-value0.0386
Key formulas
  • C2=RANK.AVG(B2,$B$2:$B$18,1)Rank among all 17, ties averaged
  • B22=SUMIF($A$2:$A$18,B19,$C$2:$C$18)Rank sum of the old app
  • B23=B22-B20*(B20+1)/2U for the old app
  • B27=SQRT(B20*C20*(B20+C20+1)/12)SD of U if there is no difference
  • B29=2*NORM.S.DIST(-ABS(B28),TRUE)Two-sided p-value

No tie correction is applied here. With a single tie the difference is negligible.

Step 1: rank all values together

Put the data in one long column with a group label next to each value, then rank every value against all values: =RANK.AVG(B2,$B$2:$B$18,1). The last argument 1 ranks in ascending order, so the fastest delivery gets rank 1. RANK.AVG gives tied values the average of the ranks they share. Two deliveries took 29 minutes, one with each app, and share ranks 3 and 4, so both get 3.5. RANK.EQ would give both a 3, and the rank sums would no longer add up.

Check: the ranks of N values always add up to N(N + 1)/2. With 17 deliveries that is 153, and 93.5 + 59.5 = 153.

Step 2: rank sums and U

Add up the ranks of each group with =SUMIF($A$2:$A$18,"Old",$C$2:$C$18): R = 93.5 for the old app and 59.5 for the new one. Then subtract the smallest rank sum the group could possibly have:

U = R − n(n + 1)/2

For the old app that is 93.5 − 8 × 9 / 2 = 57.5, for the new app 59.5 − 9 × 10 / 2 = 14.5. U counts how often a value from one group is larger than a value from the other, ties counting half. The two U values always add up to n₁ × n₂, here 57.5 + 14.5 = 72 = 8 × 9, a quick check that the ranking is right. The test statistic is the smaller U, 14.5.

Step 3: z-score and p-value with the normal approximation

If both apps were equally fast, U would be around n₁n₂/2 = 36. Its standard deviation is √(n₁n₂(n₁ + n₂ + 1)/12) = √(8 × 9 × 18 / 12) = 10.392. The z-score is (14.5 − 36) / 10.392 = −2.069, and the two-sided p-value is

=2*NORM.S.DIST(-ABS(z),TRUE) = 0.0386

That is below 0.05, so you reject the hypothesis that both apps deliver equally fast. With groups this small the normal approximation is rough, so it is worth checking an exact table as well: for groups of 8 and 9, the two-sided 5% critical value of U is 15, and 14.5 is below it, which gives the same answer.

How to report the result

Report the medians and group sizes, not the means, because the test works on ranks: "Deliveries with the new app (median 31 minutes, n = 9) were faster than with the old app (median 39.5 minutes, n = 8), Mann-Whitney U = 14.5, z = −2.07, p = 0.039." Strictly, the test shows that values in one group tend to be larger than in the other. It is a test of medians only if both distributions have the same shape. If readers need a sense of size, add an effect size such as the rank-biserial correlation next to the p-value.

Ties, continuity correction and exact tests

Ties make the standard deviation of U slightly smaller, and statistics packages apply a tie correction automatically. With one tie in 17 values, as here, the effect is negligible, but with many ties, such as ratings from 1 to 5, apply the correction or the p-value will be a little too large. Some textbooks also subtract 0.5 from |U − mean| as a continuity correction, which makes the test slightly more conservative. With fewer than about 10 values per group, read the critical value from an exact table instead. To see why skewed data needs a rank test in the first place, plot it with a histogram in Excel, and to plan how many observations an experiment needs, see the A/B test sample size guide.

Common mistakes

  • Ranking each group separately. The ranks must come from all values together. Otherwise both rank sums start at 1 and U means nothing.
  • Using RANK.EQ with ties. Tied values must share the average rank. RANK.EQ gives them the same lower rank, and the rank sums no longer add up to N(N + 1)/2.
  • Losing track of the direction. Ranking in descending order gives the same test, but the smaller U then belongs to the other group. Rank ascending and say so.
  • Using it on paired data. Before-and-after measurements on the same people need the Wilcoxon signed-rank test.
  • Reporting means. The test works on ranks, so report the medians and the group sizes.
  • Trusting the normal approximation with tiny groups. With fewer than about 10 values per group, check an exact table.

Frequently asked questions

Does Excel have a Mann-Whitney U test function?

No. Excel has T.TEST for t-tests but no rank-sum test. You build it from RANK.AVG, SUMIF, a few arithmetic steps and NORM.S.DIST for the p-value, as in the example.

Is the Mann-Whitney U test the same as the Wilcoxon rank-sum test?

Yes, they are equivalent tests for two independent groups. The Wilcoxon rank-sum statistic is the rank sum R, and U is R minus n(n + 1)/2, so both lead to the same p-value. The Wilcoxon signed-rank test is a different test, for paired data.

When should I use Mann-Whitney instead of a t-test?

When the two groups are independent and the data is clearly skewed, has outliers or is ordinal, especially with small samples. With large, roughly symmetric samples the t-test and Mann-Whitney usually agree.

Which U do I use, the smaller or the larger?

For a lookup in an exact table, the smaller U. For the normal approximation either works in a two-sided test, because both give the same absolute z-score.

Practise it in a lab

Related guides

Reading is step one. Doing is step two.

Every guide links to a lab where you build the same calculation in an online spreadsheet and get instant feedback.

Open the lab