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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
SabineOussi
Skilled Sharer
Skilled Sharer

Raking within a group

Hello,

 

I am trying to represent sections averages in different schools from the highest section average to the lowest within each school.

Below is an example, each school is represented by a color and each section is represented by a bar.

Sections Averages.PNG

 

I tried that with a column chart and I can only sort by section (alphabetically) or by average (numerically).

 

I tried this ranking:
Rank = RANKX(VALUES([School Name]), RANK.EQ(1, [Final_average], ASC), ,ASC, Skip) 
but it didn't make any sense.

 

Any help on how can this be achieved in PBI?

 

Thanks.

3 REPLIES 3
Anonymous
Not applicable

Hi @SabineOussi,

 

You can use below formula to calculate the each rank of school, then use a clstered column chart to show the result.

 

Source table:

 

Capture2.PNG

 

Calculate column:

 

Ranking = RANKX(FILTER(Sheet2,Sheet2[School]=EARLIER(Sheet2[School])),[Average],[Average],DESC,Dense)

 

 

Visual:

 

Capture.PNG

 

Regards,

Xiaoxin Sheng

Thank you @Anonymous

 

Unfortunately I am connected to a complex database and there are a lot of selections through slicers in order to come with this particular graph.

So your solution is giving me the overall rank of the sections and not on that particular selection, so it's not really by school.

 

What I did is convert the schools to a high value number and add that number to the raking column and have my chart sorted by that.

School_Ranking: School1 = 100000, School2 = 200000
Final_Ranking: School_Ranking + Ranking

And finally sections are ranked correctly according to their schools.

 

ranking.PNG

 

One thing remains is to re-rank these sections from 1 to n instead of that big number under each bar.

 

Any thoughts?

Anonymous
Not applicable

Hi @SabineOussi,

 

Perhaps you can try to calculate the new rank based on the filtered columns.

 

Regards,

Xiaoxin Sheng

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.