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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Radhika2605
Helper II
Helper II

Help with a visual

Hi, can someone please help me with this one?

 

I am working on an olympics database and I am trying to find out Top 5 countries with highest medals and in that visual I also want to show the different types of medals. 

 

I want to use Dax to show the Top 5 countries and don't want to use the filter pane.

 

The Dax measure which I am using to find the top 5 countries with highest medals is -

Top 5 Countries with highest medals =
CALCULATE(
[Total Medals],
FILTER(
VALUES( Country[Region] ),
RANKX( ALL( Country[Region] ), [Total Medals], , DESC ) <= 5 ))
 
I am trying to create a horizontal bar chart created as follows -
Axis - Region
Legend - Medal
Values - Top 5 Countries with highest medals
 
If I dont put the medal as legend then only 5 countries are returned as shown below:
Radhika2605_0-1629811499623.png

 

 

But as soon as I put the Medal in legend then I get 6 countries instead of 5-

Radhika2605_1-1629811547845.png

 

 

Can someone please guide me as to what am I doing wrong due to which 6 countries are being shown in visual instead of 5. Also, in the Top 5 Countries with highest medals measure, if I use 10 to find top 10 countries instead of top 5 and when I have medals in Legend then I get 12 results. 

 

My model -

Radhika2605_3-1629811723653.png

 

 

Thanks in advance!

Radhika

2 REPLIES 2
Greg_Deckler
Super User
Super User

@Radhika2605 Can you share the PBIX? Going to be easier to see what is going on that way.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Hi @Greg_Deckler 

Thanks for your response. Sorry file is a mess but still attaching it here.


Here is the file - 

https://drive.google.com/file/d/1WXp9F9w7cbMAr7IrtWh2Mxsj2ZlwaB70/view?usp=sharing

 

Thanks

Radhika

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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