HomeGoogle DocsSpreadsheetCalculating Percentile for Each Group in Google Sheets

Calculating Percentile for Each Group in Google Sheets

Published on

At present, to calculate the percentile for each group, there is no dedicated function in Google Sheets.

We can use a combination of either of the FILTER or IF with PERCENTILE for the same.

Why should one want to calculate group-wise percentile (group-wise centile) in Google Sheets?

Assume you have a table that contains marks of students in two different grades (classes).

To get the 75% centile of all the marks, you can straightaway use the PERCENTILE function.

Syntax: =percentile(all_marks,0.75)

But when you want to calculate the centile for each grade (class), then the function alone won’t work. Here we can use the said combination.

I hope, you could understand the term group-wise percentile in Google Sheets.

Before going to an example that contains marks and grades, here are a few more details.

You may be familiar with the statistical functions AVERAGE, MIN, MAX, MEDIAN, RANK, etc. Unlike these functions, PERCENTILE may not be most common in use.

So, I think it’s wise to give you some idea about this statistical function.

In short, what MEDIAN returns in a numerical dataset will be equal to 50th centile.

For example, the MEDIAN of the numbers 5 and 6 will be 5.5. No doubt, the 50th centile of these numbers will also be the same value.

Also, please note that both the functions interpolate to determine the value at the 50th percentile.

How to Calculate k-th Percentile for Each Group in Google Sheets

k-th: The percentile value in the range 0 to 1 (0% to 100%), inclusive (for example, you can specify 0.6 or 60% as the k-th percentile).

Sample Data: A1:C

Percentile for Each Group in Google Sheets - Example

To get the 60th centile of all the marks, we can use the below formula.

=percentile(C2:C18,0.6)

Result: 81.20

It means, 81.20 is the 60th percentile mark in this set. We can say 60 percent of students scored below 81 marks.

Group Wise Percentile in Google Sheets

Please refer to the image above for the result in the cell range F3:F5. Here are the steps to follow.

Steps:-

1. The first step here is to get the group (here grades in column B) without duplicates. For that, insert the below UNIQUE formula in cell E3.

=sort(unique(B2:B))

It will return the grades;

Grade 1, Grade 2, and Grade 3.

2. Now we can start calculating the percentile for each of these Groups in Google Sheets. For that, as I have mentioned, we can use a combination of FILTER and PERCENTILE functions.

Key the below formula in cell F3 and drag-down to F4 and F5.

=percentile(filter($C$2:$C,$B$2:$B=E3),0.6)

The FILTER formula filters the marks in C2:C based on the Grade in E3, i.e., $B$2:$B=E3. The PERCENTILE then returns the 60th centile of this filtered group.

This PERCENTILE and IF combination will also serve the purpose.

=ArrayFormula(percentile(if($B$2:$B=E3,$C$2:$C),0.6))

Here the IF formula returns the marks if the Grade matches, else FALSE.

Creating a Percentile Column

Here is one more example. Here we are calculating the percentile for each group in a new column for all the rows.

Didn’t get it?

Please see column D in the below example.

The change is in the FILTER formula criterion part.

In the above example, the FILTER uses the UNIQUE output as the criterion to filter the marks. Here instead, it uses the condition from the table (column B) itself.

=percentile(filter($C$2:$C,$B$2:$B=B2),0.6)
Percentile Column - Sheets

Note:– For the calculation, the data doesn’t need to sort.

That’s all.

Thanks for the stay. Enjoy!

Resources:

Prashanth KV
Prashanth KV
Your Trusted Google Sheets and Excel Guide Prashanth KV brings a wealth of experience in Google Sheets and Excel, cultivated through years of work with multinational corporations in Mumbai and Dubai. As a recognized Google Product Expert in Docs Editors, Prashanth shares his expertise through insightful blogging since 2012. Explore his blog for practical tips and guidance on maximizing your spreadsheet skills.

Appointment Schedule Template in Google Sheets

An appointment schedule template in Google Sheets can assist you in efficiently managing your...

Creating Sequential Dates in Equally Merged Cells in Google Sheets

Do you know how to create sequential dates in equally merged cells across a...

Running Total By Month in Excel

This tutorial demonstrates how to calculate the running total by month in a range...

SORT and SORTBY – Excel Vs Google Sheets

While Excel offers the SORT and SORTBY functions for sorting a table, Google Sheets...

More like this

Appointment Schedule Template in Google Sheets

An appointment schedule template in Google Sheets can assist you in efficiently managing your...

Creating Sequential Dates in Equally Merged Cells in Google Sheets

Do you know how to create sequential dates in equally merged cells across a...

Interactive Random Task Assigner in Google Sheets

You have multiple tasks and multiple people. Here's a fun way to randomly assign...

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.