Starting December 3, join live sessions with database experts and the Microsoft product team to learn just how easy it is to get started
Learn moreGet certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now
I am relatively new to DAX and I have been trying to use RANKX to filter the top 3 medalists as seen below.
This is the result, which is true (Neglecting the total)
But the moment I try to map the ID to name and gender (both are in another table, see below) it starts to acting in a unexpected way. For Example (is this top 3 for each gender?)
This is what I am trying to achieve (This was by using Top N in the Filter panel but I want to use DAX instead).
Data model
Hi @Anonymous ,
Can you share some sample data so that we could check the formula?
Best Regards,
Jay
Hi, @v-jayw-msft
This is just a personal project to gain hands on experience using Power BI, so feel free to view the whole file.
I created a report page called "TESTING TOP N" where you can check the formula and what I am trying to achieve.
Thank you in advance.
You can try an expression like this one.
Top 3 Medal Count =
VAR top3 =
TOPN ( 3, ALLSELECTED ( 'Medalists'[ID] ), [Total Medals Medalists], DESC )
VAR result =
CALCULATE ( [Total Medals Medalists], KEEPFILTERS ( top3 ) )
RETURN
result
Pat
To learn more about Power BI, follow me on Twitter or subscribe on YouTube.
@Anonymous , Try TOPN
example
calculate([total medal medlist],TOPN(3,allselected(Table[ID]),[total medal medlist],DESC), values(Table[ID]))
TOPN: https://www.youtube.com/watch?v=QIVEFp-QiOk&list=PLPaNVDMhUXGaaqV92SBD5X2hk3TMNlHhb&index=42
Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.
User | Count |
---|---|
92 | |
87 | |
84 | |
65 | |
49 |
User | Count |
---|---|
140 | |
114 | |
110 | |
59 | |
59 |