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

Get 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

Reply
Radhika2605
Helper II
Helper II

Need help with measure

Hi Everyone,

 

I am working on an olympics data set and I am trying to find the top 10 atheletes using dax measure but instead of giving 10 results it is returning more than 10 results. 

 

Dax measure used- 

Top N Atheletes with maximum medals =
CALCULATE(
[Total Medals],
FILTER( VALUES( Athlete[Name] ),
RANKX( ALL( Athlete[Name] ), [Total Medals], , DESC ) <= 10 )
 
Here are the results-
Radhika2605_0-1629899797655.png

 

 

Is it because the total number of medals has duplicate values or there is something wrong in my logic. Could you please guide me as to how can I get exactly 10 values even when total number of medals won by atheletes is duplicated.

 

My model is - 

Radhika2605_1-1629899910019.png

 

 

Thanks

Radhika

2 ACCEPTED SOLUTIONS
ryan_mayu
Super User
Super User

@Radhika2605 

that depends on how you want to choose the top 10 when total medals is dpulicated.

let's say by name.

_name=max( Athlete[Name] )

_rank=RANKX( ALL( Athlete[Name] ), [Total Medals], , DESC ) +RANKX( ALL( Athlete[Name] ), _name,DESC)/10

then you will get no duplicated rank.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

@Radhika2605 

it looks you have hundreds of names. pls try to change /10 to /100 or /1000





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

9 REPLIES 9
Radhika2605
Helper II
Helper II

Hi Ryan,

 

One last thing on this one - when I am trying to create a stacked bar chart for these top 10 athletes and trying to bring the medal type(gold, silver and bronze) in the legend field then instead of showing 10 values it shows a lot of athletes. Left side is the measure we just created and right side is all the athelets and their medals. Even the distribution of medals shown in our meausre looks to be incorrect as it is not showing the bronze measures. This only happens when I bring medal type in legend.

Radhika2605_2-1629970587948.png

 

 

What should I do for this?

 

Thanks

Radhika

@Radhika2605 

i did a test. maybe you can create a new table and create the visual based on the new table.

Table = TOPN(10,'Table',RANKX(all('Table'[name]),rankx(ALL('Table'[name]),[_sum],,DESC)+RANKX(all('Table'[name]),[_name],,ASC)/10,,ASC))




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




@ryan_mayu Thanks so much for this, I will give it a try.

 

Thanks

Radhika

ryan_mayu
Super User
Super User

@Radhika2605 

that depends on how you want to choose the top 10 when total medals is dpulicated.

let's say by name.

_name=max( Athlete[Name] )

_rank=RANKX( ALL( Athlete[Name] ), [Total Medals], , DESC ) +RANKX( ALL( Athlete[Name] ), _name,DESC)/10

then you will get no duplicated rank.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Hi @ryan_mayu 

Thank you so much for your prompt response.

 

Could you please explain the logic you used a bit as I am unable to comrehend it (sorry still at beginner). Also, I tried to use what you suggested but it is giving error as shown in the screenshot below: 

Radhika2605_0-1629901323383.png

 

 

Thanks

Radhika

@Radhika2605 

here is a workaround for you. pls see the attachment below

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Hi @ryan_mayu,

 

Thanks for you effor in sending the solution. I did tried it but the issue is it is still not giving the correct result. the result which I am getting is on the left. 

Radhika2605_0-1629964529740.png

 

Right hand table is the table which shows the total number of medals won and I have arrange it in descending order according to the number of medals. It shows that the highest medal won is 58, then 39 and then 38. 

 

But the tabel on the left only has values for athelete names starting from alphabet A. I think it is arranging it in alphabetical order or something. 

 

how should the solution which you have provided needs to be refined for it to work properly? 

Thanks in advance

Radhika

@Radhika2605 

it looks you have hundreds of names. pls try to change /10 to /100 or /1000





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Hi @ryan_mayu 

 

You are a legend!!

It worked, thank you so much for your assistance.

 

Thanks

Radhika

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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