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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
thaller
New Member

Dynamic ranking based on a matrix

Hi all,

 

I am rather new to PowerBI and I am trying to get a dynamic ranking. My current data is structured as follows:

Trade IDDateAsset ClassBrokerTrade amount
X0000110.01.2019CreditBARCLAYS     50 000 000.00
X0000220.06.2019CreditBARCLAYS     25 000 000.00
X0000320.01.2020CreditJPM     15 000 000.00
X0000420.01.2020CreditJPM     20 000 000.00
X0000530.03.2020MBSRBC     60 000 000.00
X0000619.12.2019MBSBNP   800 000 000.00
X0000721.02.2021MBSBARCLAYS        3 000 000.00
X0000804.03.2020MBSBNP     40 000 000.00
X0000910.01.2019CreditJPM     50 000 000.00
X00001020.06.2019MBSBARCLAYS     25 000 000.00
X00001120.01.2020CreditJPM     15 000 000.00
X0000721.02.2021MBSBNP        6 000 000.00

 

I would like to be able to rank each brokers within each asset class for each different year (e.g. BARCLAYS is best broker in 2019 for Credit). The criterion for ranking would be the sum of trade values (highest sum = highest ranking). As an intermediary result I think the matrix should look like the following:

 Credit MBS  
 20192020201920202021
BARCLAYS                  1                 2                 2
BNP                  1                              2                1
JPM                  2                              1   
RBC                                 1 

 

Utlimately I would like to display the results by single broker in the report as follows

Barclays201920202021
Credit100
MBS202

 

A contraint is that I need to keep these rankings dynamic as the user can:

- determine the time frame (e.g. ranking only on the time period 07/2019-06/2020)

- determine which broker to integrate 

Therefore I don't find it possible to implement a ranking by measures at the database level because it is then unaffected by the time slider.

 

Any help would be appreciated

Thank you

Thomas

1 REPLY 1
amitchandak
Super User
Super User

@thaller ,

 

rankx(allselected(Table[Broker]), calculate(Sum(Table[amount])))

 

rankx(filter(allselected(Table[Broker],table[Year]), [Year] =max([Year])), calculate(Sum(Table[amount])))

 

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...

 

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

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

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 community update carousel

Fabric Community Update - June 2025

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