How to Perform a Kruskal-Wallis Test in Excel

A Kruskal-Wallis Test is used to determine whether or not there is a statistically significant difference between the medians of three or more independent groups. It is considered to be the non-parametric equivalent of the One-Way ANOVA.

This tutorial explains how to conduct a Kruskal-Wallis Test in Excel.

Example: Kruskal-Wallis Test in Excel

Researchers want to know if three different fertilizers lead to different levels of plant growth. They randomly select 30 different plants and split them into three groups of 10, applying a different fertilizer to each group. At the end of one month they measure the height of each plant.

Use the following steps to perform a Kruskal-Wallis Test to determine if the median growth is the same across the three groups.

Step 1: Enter the data.

Enter the following data, which shows the total growth (in inches) for each of the 10 plants in each group:

Step 2: Rank the data.

Next, we will use the RANK.AVG() function to assign a rank to the growth of each plant out of all 30 plants. The following formula shows how to calculate the rank for the first plant in the first group:

Copy this formula to the rest of the cells:

Then, calculate the sum of the ranks for each column along with the sample size and the squared sum of ranks divided by the sample size:

Step 3: Calculate the test statistic and the corresponding p-value.

The test statistic is defined as:

H = 12/(n(n+1)) * ΣRj2/nj – 3(n+1)

where:

• n = total sample size
• Rj2 =sum of ranks for the jth group
• nj =sample size of jth group

Under the null hypothesis, H follows a Chi-square distribution with k-1 degrees of freedom.

The following screenshot shows the formulas used to calculate the test statistic, H, and the corresponding p-value:

The test statistic is H = 6.204 and the corresponding p-value is p = 0.045. Since this p-value is less than 0.05, we can reject the null hypothesis that the median plant growth is the same for all three fertilizers. We have sufficient evidence to conclude that the type of fertilizer used leads to statistically significant differences in plant growth.

Step 4: Report the results.

Lastly, we want to report the results of the Kruskal-Wallis Test. Here is an example of how to do so:

A Kruskal-Wallist Test was performed to determine if median plant growth was the same for three different plant fertilizers. A total of 30 plants were used in the analysis. Each fertilizer was applied to 10 different plants.

The test revealed that the median plant growth was not the same (H = 6.204, p = 0.045) among the three fertilizers. That is, there was a statistically significant difference in median plant growth among two or more of the fertilizers.

29 Replies to “How to Perform a Kruskal-Wallis Test in Excel”

1. kt says:

The formaula doesnt explain how you got the p value though??

2. Jen says:

This is great! However, how did you get the p value? There is no formula and guidance on this. Thanks

3. Sam says:

how did you create the final pvalue? Everything else is clear

4. Eugenia Mouresioti says:

This article has been really helpful for my data analysis. In my study, participants were asked to evaluate language users on a variety of traits by using a 6 point Likert scale. I have divided the participants by gender, age and educational background, and I want to test how different their opinions were by performing a Kruskal Wallis test. I have followed every step that is well explained here, but I have difficulties with calculating the p value and I was wondering if I could get some help.

5. Samantha G says:

How do you determine the corresponding p-value from the calculated H-statistic?

6. fran says:

7. Jay says:

Hey, great explanation! But, can you explain how you got the p-value in step 3?

8. Xyron says:

Well structured, but how do I calculate the p-value? You just added a random number in the excel sheet.

9. Filip Luther Naude Swart says:

Hi,
How did you calculate the p-value?

10. Bryanna says:

How did you get the p-value from the H score?

Today is good day

12. Maged Hussein says:

Thank you very much for valuable information and simple scientific language

13. kt m says:

Hello,
how are we calculating the pvalue?
thanks!

14. Jordan says:

How do you get the p-value?

15. Mateo says:

How do you calculate p-value (0.045)?

Thanks

16. Ann Smith says:

This was so great step by step… up until the p value which appeared to be pulled out of thin air… how did you get 0.045? Also I got a negative H value… which I don’t know is valid…

17. Fair frank says:

Where is the formula for calculating p value. It is not visible on your screenshots

18. ilan K says:

i have a question. how was the p value calculated? there is no mention of formula and in the screenshot its just the value

19. Ina says:

Hello Zach.
First I would like to thank you for this tutorial.
In step 3 you showed the formula for the test statistic H and the p-value. Sadly I couldn’t find the formula for the p-value.
I would really appreciate it, if you could send/write me the formula for the p-value, since I’m just starting to learn about statistics and the Kustal-Wallis-Test.

Sincerely
Ina

20. William Robson says:

How did you calculate the P-value? the formula is not shown in the screenshot… besides that, this has worked brilliantly! Thank you!

21. Eve says:

How did you find the p-value? if there’s an excel formula its greatly appreciated

22. tami says:

how did you calculate the p value at the end?

Excellent thank you very much

24. Maja Holm says:

Thank you!
However. How do I calculate the p-value? It’s not included in the instructions.

25. Amerida Lakot says:

Very precise and clear steps…i easily understood the entire process. Thank you

26. Tommy says:

So how did you come up with the value for p?

27. Zhang says:

How to compute P-vlaue? P-value formula?

28. Alani Sulaimon Akanmu says:

I tried to the examples given and I was not sure that using the data used in the examples I did not get the same results.
In the formula for calculation of H, 12 was substituted for n instead of 130 that was supposed to be sample size
So I am not so sure I understand the logics very well

29. Reylin says:

Where did the p value come from?