Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
saurabhk18
Contributor II
Contributor II

Calculate fractile across dataset

Hi,

My research on the Fractile expression tells me that it requires a field to be grouped by. But what if I want to calculate it across the entire dataset? Let's say I have a table with the marks for 10 students:

IDMarks
199
289
379
488
590
681
767
889
990
1068

 

I wish to calculate the quartile each individual score belongs to. As 67 is the lowest score, it would belong to the first quartile, and 99 being the highest would belong to the fourth. But if I were to use Fractile(Marks, 0.25), Fractile(Marks, 0.5) etc, I would need to apply a group by clause, which wouldn't make sense here.

As a workaround, I can load only the marks in a separate table, define '1' as the ID for each row, and then group by ID to calculate the fractile. I can then use this as a mapping table for the original table. But this is a lengthy approach if you have to calculate fractiles for multiple fields (assuming the table also had IQ, weight etc.). Can you suggest something quicker?

Thanks!

-Saurabh

Labels (2)
1 Solution

Accepted Solutions
sunny_talwar

Seems like you are trying to do this in the script. If you are, then you can just do a join to your main table like this

Join (TableName)
LOAD Fractile(Marks, 0.25),
     Fractile(Marks, 0.50),
     Fractile(Marks, 0.75)
Resident TableName;

View solution in original post

1 Reply
sunny_talwar

Seems like you are trying to do this in the script. If you are, then you can just do a join to your main table like this

Join (TableName)
LOAD Fractile(Marks, 0.25),
     Fractile(Marks, 0.50),
     Fractile(Marks, 0.75)
Resident TableName;