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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

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
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Kudoed Authors