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
DeepDive
Helper IV
Helper IV

Can we use RankX with drilleddown option ?

I have Customer, Country, Product, and Sales Value.. I want to use Rankx on customer but when i drilled it down further on country level... it will show rank of customer within in country(single) and same for Product like rank of Customers in one country for single producte... I want to use matrix here (and also can we use group by to get top 5 customers and rest in others ).. Experts pls help

1 ACCEPTED SOLUTION

It took me a bit, but I was able to find this blog post that explained exactly how to do it.  I've updated their expression to use ISINSCOPE, which works better for matrices.

Rank = 
IF( ISINSCOPE(Sales_Data[Product]), RANKX(ALL(Sales_Data[Product]), CALCULATE(SUM(Sales_Data[Sales]))),
    IF( ISINSCOPE(Sales_Data[Country]), RANKX(ALL(Sales_Data[Country]), CALCULATE(SUM(Sales_Data[Sales]))), 
        IF(ISINSCOPE(Sales_Data[Customer]), RANKX(ALL(Sales_Data[Customer]), CALCULATE(SUM(Sales_Data[Sales]))))
    )
)

This will return the rank for whatever scope you're currently in.  Using this, I was able to create this visual, where the rank responds to the current level of drilldown, and will still rank against values that are filtered out of the visual:

snipa.PNG

View solution in original post

5 REPLIES 5
v-diye-msft
Community Support
Community Support

Hi 

 

We can barely replicate your issue, plz kindly share more details, thanks.

 

Community Support Team _ Dina Ye
If this post helps, then please consider Accept it as the solution to help the other members find it more
quickly.

Dear all,

am using below DAX, did some R&D also but unable to get the desired reult. 

 

Rank_Customer =

IF(HASONEVALUE(Sales_Data[Customer]),
CALCULATE(RANKX(ALL(Sales_Data[Customer]), [Total_Value],,DESC,Dense), ALLSELECTED(Sales_Data[Country]), ALLSELECTED(Sales_Data[Product])),
BLANK()
)
 

 

 

 

 

 

It took me a bit, but I was able to find this blog post that explained exactly how to do it.  I've updated their expression to use ISINSCOPE, which works better for matrices.

Rank = 
IF( ISINSCOPE(Sales_Data[Product]), RANKX(ALL(Sales_Data[Product]), CALCULATE(SUM(Sales_Data[Sales]))),
    IF( ISINSCOPE(Sales_Data[Country]), RANKX(ALL(Sales_Data[Country]), CALCULATE(SUM(Sales_Data[Sales]))), 
        IF(ISINSCOPE(Sales_Data[Customer]), RANKX(ALL(Sales_Data[Customer]), CALCULATE(SUM(Sales_Data[Sales]))))
    )
)

This will return the rank for whatever scope you're currently in.  Using this, I was able to create this visual, where the rank responds to the current level of drilldown, and will still rank against values that are filtered out of the visual:

snipa.PNG

Post-Untitled.png

Cmcmahan
Resident Rockstar
Resident Rockstar

Can you share the DAX expression you're using RANKX in?  You likely just need to add in an ALL statement to your syntax, but without knowing what it looks like, I can't help much.

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.