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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
AnniekH96
Frequent Visitor

Ranking among three groups > return name of top 2

Hi everyone, 

 

I got a large dataset(2M> rows) with 5 columns:

  • Institution
  • Year
  • Region
  • Course
  • Number of students

I want to rank the within each year, region and course the number of students. For example the first 4 rows have the same year, region and course so they get ranked together. 

 

Secondly, I want a column(or measure) that returns the institution of the highest two ranking institution, all others get the label "Others."

 

I can't seem to find a rankx that allows the multiple groups. I would really appreciate some help!!

 

InstitutionYearRegionCourseNumber op studentsRankingGrouping
30RR2019Frieslandtotaal;008;bbl;415230RR
30RM2019Frieslandtotaal;008;bbl;4123Others
25PJ2019Frieslandtotaal;008;bbl;447125PJ
08PG2019Frieslandtotaal;008;bbl;434Others
25PJ2019Frieslandtotaal;057;bbl;416125PJ
08PG2018Frieslandtotaal;008;bbl;438108PG
25PJ2018Frieslandtotaal;008;bbl;434225PJ
30RM2018Frieslandtotaal;008;bbl;4303Others
AATR2018Frieslandtotaal;008;bbl;4124Others
30RM2019Midden-Utrechttotaal;057;bbl;412130RM
30RR2019Midden-Utrechttotaal;008;bbl;417230RR
30RM2019Midden-Utrechttotaal;008;bbl;439130RM
25PJ2019Midden-Utrechttotaal;008;bbl;425Others
08PG2019Midden-Utrechttotaal;008;bbl;434Others 
AATR2019Midden-Utrechttotaal;008;bbl;4153Others
30RM2018Midden-Utrechttotaal;057;bbl;444130RM
30RR2018Midden-Utrechttotaal;057;bbl;47230RR
30RR2018Midden-Utrechttotaal;008;bbl;425230RR
25LG2018Midden-Utrechttotaal;008;bbl;438125LG
1 REPLY 1
amitchandak
Super User
Super User

@AnniekH96 , If [Number op students] is a column and you need column rank .

 

If nedd measure rank. Make sure [Number op students] is measure or create a measure and use that in rank = sum(Table[Number op students])

 

Rankx(filter(Table, [year] =earlier([year]) && [region] =earlier([region]) && [course] =earlier([course]) ),[Number op students])

Rankx(filter(allselected(Table[Year], Table[region], Table[course]), Table[, [year] =earlier([year]) && [region] =earlier([region]) && [course] =earlier([course]) ),[Number op students])

 

For Rank Refer these links
https://radacad.com/how-to-use-rankx-in-dax-part-2-of-3-calculated-measures
https://radacad.com/how-to-use-rankx-in-dax-part-1-of-3-calculated-columns
https://radacad.com/how-to-use-rankx-in-dax-part-3-of-3-the-finale
https://community.powerbi.com/t5/Community-Blog/Dynamic-TopN-made-easy-with-What-If-Parameter/ba-p/3...

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.

Top Kudoed Authors