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:

Raw data in three columns in Excel

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)


  • 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:

 Kruskal Wallis test calculation in Excel

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. This is great! However, how did you get the p value? There is no formula and guidance on this. Thanks

  2. 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.
    Thank you in advance!

  3. 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…

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

  5. 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.


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

  7. 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

Leave a Reply

Your email address will not be published. Required fields are marked *