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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Sage2019
Frequent Visitor

Ranking top 4 including selected item in the same category

Hi 
I would like to visualize the top 4 including the one selected item from the same group or category. 

For example, the top 4 countries and their population including the country that is selected in the slicer. this compares the other 4 countries with the highest population with the selected country in the same region. 
While I can get the top 4 and rank it, I am not sure how I can get the selected country in it as well.

3 REPLIES 3
v-cgao-msft
Community Support
Community Support

Hi @Sage2019 ,

first create a un-connect table for the slicer:

vcgaomsft_1-1709275831733.png

and then please create a new measure for the visual's filter:

Filter = 
VAR __ranking = RANKX(ALLSELECTED('Table'[Country]),[Total Population])
VAR _select_value = ALLSELECTED('DimCountry'[Country])
VAR _result = IF(__ranking<=4 || SELECTEDVALUE('Table'[Country]) IN _select_value,1)
RETURN
_result

vcgaomsft_2-1709275921998.png

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum -- China Power BI User Group

Daniel29195
Super User
Super User

Hello @Sage2019 

 

can you please share a sample data and the output of what you want to achieve ? 

 

best regards,

@Daniel29195 , @v-cgao-msft 

CountryRegionPopulation
ANorth500,000
BNorth460000
CNorth80000
DWest240000
FWest390249
GEast94239
HWest139403
IEast293131
JNorth60000

 

my country slicer is a field in the Dim Country Table that is connected to my Population table. 

The results I want to achieve is if I single select J as the country I should see J in the visual along with the top 3 or 4 countries in the same region North. Therefore the visual should have A,B and J if it's the top 3 or A,B,C and J if top 4

Helpful resources

Announcements
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!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.