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 August 31st. Request your voucher.

Reply
Anonymous
Not applicable

Rankx on a matrix

i am trying to do rankx on a matrix table but when i drill down i would like the rankx to recalculate when i drill down, currently i have the following fields in my matrix and want to do the rank by total sales. Any help would be amazing;

 

Superdeathmonke_0-1597670678499.png

 

8 REPLIES 8
v-xicai
Community Support
Community Support

Hi @Anonymous ,

 

You may create measure like DAX below .

Endleaf Rank =
SWITCH (
    TRUE (),
    ISINSCOPE ( Sales[Username] ), RANKX (
        ALLSELECTED ( Sales[Username] ),
        CALCULATE ( SUM ( Sales[Point] ) ),
        ,
        DESC,
        DENSE
    ),
    ISINSCOPE ( Sales[Date].[Month] ), RANKX (
        ALLSELECTED ( Saless[Date].[Month] ),
        CALCULATE ( SUM ( Sales[Point] ) ),
        ,
        DESC,
        DENSE
    ),
    ISINSCOPE ( Sales[store]]] ), RANKX (
        ALLSELECTED ( Store[store] ),
        CALCULATE ( SUM ( Sales[Point] ) ),
        ,
        DESC,
        DENSE
    ),
    ISINSCOPE ( Sales[Product]]] ), RANKX (
        ALLSELECTED ( Store[Product] ),
        CALCULATE ( SUM ( Sales[Point] ) ),
        ,
        DESC,
        DENSE
    )
)

 

Best Regards,

Amy 

 

Community Support Team _ Amy

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

thanks amy, still not geting the outcome i would expect as i am still getting just loads of 1 when i drill down;

 

Superdeathmonke_0-1597745670577.png

 

amitchandak
Super User
Super User

@Anonymous ,Can you share sample data and sample output in table format?

For Rank Refer these links
https://radacad.com/how-to-use-rankx-in-dax-part-2-of-3-calculated-measures
https://radacad.com/how-to-use-rankx-in-dax-part-1-of-3-calculated-columns
https://radacad.com/how-to-use-rankx-in-dax-part-3-of-3-the-finale
https://community.powerbi.com/t5/Community-Blog/Dynamic-TopN-made-easy-with-What-If-Parameter/ba-p/367415

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Greg_Deckler
Community Champion
Community Champion

@Anonymous - https://community.powerbi.com/t5/Quick-Measures-Gallery/To-Bleep-with-RANKX/m-p/1042520#M452



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
harshnathani
Community Champion
Community Champion

Hi @Anonymous ,

 

Please share sample data and expected output.

 

Regards,
Harsh Nathani
Did I answer your question? Mark my post as a solution! Appreciate with a Kudos!! (Click the Thumbs Up Button)

Anonymous
Not applicable

@harshnathani currently if i am just looking at the table before i drill down from user the ranking is current using;

 

Rankx(all(username),[Total Sales])

 

but when i drill down to month it just gives me 1 on everything then when i further drill down to the other options it is always 1 when i would expect it to recalculate and rank the months then rank the next category etc

 

 

Hi @Anonymous ,

 

Since it is matrix and you need to drill down,  you will need to use ISINSCOPE.

 

See this article

 

https://www.sqlbi.com/articles/filtering-the-top-3-products-for-each-category-in-power-bi/

 

 

Regards,

Harsh Nathani

Anonymous
Not applicable

@harshnathani i have tried doing ISINSCOPE and dont get any different result it is still just giving me a 1 for everything when i drill down;

 

Endleaf Rank =
SWITCH(
TRUE(),
ISINSCOPE(Sales[Username]), RANKX(ALLSELECTED(Sales[Username]),[Total Points], ,DESC,Dense),
ISINSCOPE(Sales[Date].[Month]),RANKX(ALLSELECTED(Saless[Date].[Month]), [Total Points], ,DESC, Dense),
ISINSCOPE(Sales[store]]]), RANKX(ALLSELECTED(Store[store]),
[TotalSales], ,
DESC,
Dense)
)

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 Solution Authors