cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
DeepDive Member
Member

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

Accepted Solutions
Super User
Super User

Re: Can we use RankX with drilleddown option ?

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

5 REPLIES 5
Super User
Super User

Re: Can we use RankX with drilleddown option ?

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.

Community Support Team
Community Support Team

Re: Can we use RankX with drilleddown option ?

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.
DeepDive Member
Member

Re: Can we use RankX with drilleddown option ?

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()
)
 

 

 

 

 

 

DeepDive Member
Member

Re: Can we use RankX with drilleddown option ?

Post-Untitled.png

Super User
Super User

Re: Can we use RankX with drilleddown option ?

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

Helpful resources

Announcements
Community Highlights

Community Highlights

Find out what's new in the Power BI Community!

Summit North America

Power Platform Summit North America

Register by September 5 to save $200

Virtual Launch Event

Microsoft Business Applications Virtual Launch Event

Watch the event on demand for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

MBAS Gallery

Watch Sessions On Demand!

Continue your learning in our online communities.

Users Online
Currently online: 390 members 3,850 guests
Please welcome our newest community members: