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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
AceSuarilla
Frequent Visitor

Calculate ranks dynamically based on Slicer from related table

I am trying to do something similar to the one on this link: https://community.powerbi.com/t5/Community-Knowledge-Base/Calculate-ranks-dynamically-based-on-Slice...

 

Only difference is that the slicer is a column from a related table. 

 

Ex. I'm trying to rank the total sales per country, but I have a slicer for continent on a separate geo table. 

 

What I'm getting is that when I filter the data to say, Asia, the rest of the countries from the other continents are still there but they just have the same value.

 

EX: 

 

Country ContinentRank
JapanAsia1
IndonesiaAsia2
GermanyEurope3
ArgentinaSouth America3

 

I realize that I can always just add the continent to the same table and use that as the slicer, but I'm curious to know how I could do that with the current setup.

2 REPLIES 2
v-yuta-msft
Community Support
Community Support

Hi AceSuarilla,

 

Try this:

 

rank =
RANKX (
    CALCULATETABLE ( SaleTable, ALLSELECTED ( geo ) ),
    CALCULATE (
        SUM ( SaleTable[sales] ),
        ALLEXCEPT ( SaleTable, SaleTable[country] )
    ),
    ,
    DESC
)

 

Regards,

Jimmy Tao

Hi @v-yuta-msft,

 

That unfortunately didn't do it. 

 

From this sample:

SALES:

SalesCountry
550Japan
221Indonesia
543Germany
112Argentina


GEO: 

CountryContinent
JapanAsia
GermanyEurope
IndonesiaAsia
ArgentinaSouth America

 

 

What I got were these:

Filtered to Asia:

SalesCountryRank
550Japan1
221Indonesia2
 Germany2
 Argentina3

Filtered to Europe:

SalesCountryRank
 Japan1
 Indonesia2
 Germany1
112Argentina2

Filtered to South America:

SalesCountryRank
 Japan1
 Indonesia1
 Germany1
112Argentina1

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors