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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

Calculate Top Quartile with filter

Hi All, 

 

I am trying to calculate the Top Quartile of data with a filter applied. 

A subset of data looks like this: 

YearSchoolResponsesQ5
2019School 1941688.22
2019School 2909988.38
2019School 3777892.33
2019School 4757286.31
2019School 5755188.83
2019School 6653185.17
2019School 7591986.00
2019School 8587091.05
2019School 9503689.00
2019School 10450188.23
2019School 11411387.60
2019School 12402588.50
2019School 13387290.62
2019School 14362992.41
2019School 15338786.24
2019School 16318490.53
2019School 17297993.45
2019School 189878.59
2019School 199794.47
2019School 209088.77
2019School 214781.81
2019School 224580.32
2019School 233489.49

 

I am using the following formula

 

Top_Quartile_School = 
    PERCENTILEX.INC(
    ALLSELECTED(Table[School]),
        [Q5],
        .75)

 

This works generally, however I need to be able to filter and calculate the Top Quartile where responses >100 and I cant seem to build this into the measure and get it to work.

 

Notes:

I need to do this as a measure rather than create another table as I have other dashboard filters. 

Both Responses and Q5 are measures

 

I have had a look at this thread: https://community.powerbi.com/t5/Desktop/PERCENTILE-inside-CALCULATE-does-not-anymore-recognise-data... but I cant quite figure out how to get it to work. 

 

Thanks for any help

4 REPLIES 4
v-gizhi-msft
Community Support
Community Support

Hi,

 

According to your description, i create a simple table to test:

61.PNG

Responses = SUM(School[Res])
Q5 = SUM(School[Students])/CALCULATE(SUM(School[Students]),ALLSELECTED(School))

Please try this measure:

Top_Quartile_School = RANKX(GROUPBY(ALLSELECTED('School'),'School'[Year],School[School]),[Q5],CALCULATE([Q5]))

Then apply filter to the table visual, and it shows schools' rank:

62.PNG

Later, you can filter any number of top rank you want.

 

Hope this helps.

 

Best Regards,

Giotto Zhi

 

Anonymous
Not applicable

Thanks @v-gizhi-msft  this is great and I will most certainly use this somewhere in the report. 

I want to be able to calculate the top quartile of Q5 records with more than 100 responses dynamically if possible though as I need to create a visual (a lolipop graph) that shows the gap to the top quartile for each school. Is there a way to do this with percentile.inc?

amitchandak
Super User
Super User

Refer, if these can help

https://community.powerbi.com/t5/Desktop/Dynamic-Quartiles/m-p/814004

https://community.powerbi.com/t5/Desktop/Matrix-quartiles-percentiles/m-p/874703

 

Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution. In case it does not help, please provide additional information and mark me with @
Thanks. My Recent Blog -
Winner-Topper-on-Map-How-to-Color-States-on-a-Map-with-Winners , HR-Analytics-Active-Employee-Hire-and-Termination-trend
Power-BI-Working-with-Non-Standard-Time-Periods And Comparing-Data-Across-Date-Ranges

Connect on Linkedin

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Thanks @amitchandak neither of those solutions are applicable I dont think. I want to handle it within a measure and filter to >100 responses. 

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors