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
123abc
Community Champion
Community Champion

Rankx, Ranking by Region and by Zone (multiple level of hierarchy) using Matrix style table

Dear Sirs & Experts,

 

I want a DAX measure that can calculate Ranking for Main Category then furthermore 3 sub-categories based on %.

 

Necessary Reference Files and expected results is attached below link (Excel and pbix):

https://drive.google.com/file/d/1XOUWo-EyXJVcT1_6LPCWgc38pn0dkUnP/view?usp=sharing

 

Old Dax not work:

Rank =
SWITCH (
    TRUE (),
    ISINSCOPE ( ASO[ASO Name] ),
        RANK (
            SKIP,
            ALL ( ASO[ASO Name], ASO[Branch], ASO[Zone], ASO[Region] ),
            ORDERBY ( CALCULATE ( SUM ( ASO[Sales Ach] ) ), DESC )
        ),
    ISINSCOPE ( ASO[Branch] ),
        RANK (
            SKIP,
            ALL ( ASO[Branch], ASO[Zone], ASO[Region] ),
            ORDERBY ( CALCULATE ( SUM ( ASO[Sales Ach] ) ), DESC )
        ),
    ISINSCOPE ( ASO[Zone] ),
        RANK (
            SKIP,
            ALL ( ASO[Zone], ASO[Region] ),
            ORDERBY ( CALCULATE ( SUM ( ASO[Sales Ach] ) ), DESC )
        ),
    ISINSCOPE ( ASO[Region] ),
        RANK (
            SKIP,
            ALL ( ASO[Region] ),
            ORDERBY ( CALCULATE ( SUM ( ASO[Sales Ach] ) ), DESC )
        )
)

Working Design On Power BI Dashboard and Expected Results showing in Excel Sheet:

Main Workng Image.jpgExpected Ranking Results.jpg

 

 Jihwan_Kim @Ashish_Mathur  @amitchandak

 

 

1 ACCEPTED SOLUTION
123abc
Community Champion
Community Champion

According to your description, here are my steps you can follow as a solution.

(1) My test data is the same as yours.

(2) We can create a measure.

Rank = 
SWITCH (
    TRUE (),
    ISINSCOPE ( 'unique keys'[ASO Name] ),
        RANK (
            SKIP,
            ALL ( 'unique keys'[ASO Name], 'unique keys'[Branch], 'unique keys'[Zone], 'unique keys'[Region] ),
            ORDERBY ( CALCULATE ( SUM ('Sales data'[Sales Ach] ) ), DESC )
        ),
    ISINSCOPE ( 'unique keys'[Branch] ),
        RANK (
            SKIP,
            ALL ( 'unique keys'[Branch], 'unique keys'[Zone], 'unique keys'[Region] ),
            ORDERBY ( CALCULATE ( SUM ('Sales data'[Sales Ach] ) ), DESC )
        ),
    ISINSCOPE ( 'unique keys'[Zone] ),
        RANK (
            SKIP,
            ALL ( 'unique keys'[Zone], 'unique keys'[Region] ),
            ORDERBY ( CALCULATE ( SUM ( 'Sales data'[Sales Ach] ) ), DESC )
        ),
    ISINSCOPE ( 'unique keys'[Region] ),
        RANK (
            SKIP,
            ALL ( 'unique keys'[Region] ),
            ORDERBY ( CALCULATE ( SUM ( 'Sales data'[Sales Ach] ) ), DESC )
        )
)

(3) Then the result is as follows.

 

123abc_1-1701340688569.png

 

 

Best Regards,

Neeko Tang

View solution in original post

1 REPLY 1
123abc
Community Champion
Community Champion

According to your description, here are my steps you can follow as a solution.

(1) My test data is the same as yours.

(2) We can create a measure.

Rank = 
SWITCH (
    TRUE (),
    ISINSCOPE ( 'unique keys'[ASO Name] ),
        RANK (
            SKIP,
            ALL ( 'unique keys'[ASO Name], 'unique keys'[Branch], 'unique keys'[Zone], 'unique keys'[Region] ),
            ORDERBY ( CALCULATE ( SUM ('Sales data'[Sales Ach] ) ), DESC )
        ),
    ISINSCOPE ( 'unique keys'[Branch] ),
        RANK (
            SKIP,
            ALL ( 'unique keys'[Branch], 'unique keys'[Zone], 'unique keys'[Region] ),
            ORDERBY ( CALCULATE ( SUM ('Sales data'[Sales Ach] ) ), DESC )
        ),
    ISINSCOPE ( 'unique keys'[Zone] ),
        RANK (
            SKIP,
            ALL ( 'unique keys'[Zone], 'unique keys'[Region] ),
            ORDERBY ( CALCULATE ( SUM ( 'Sales data'[Sales Ach] ) ), DESC )
        ),
    ISINSCOPE ( 'unique keys'[Region] ),
        RANK (
            SKIP,
            ALL ( 'unique keys'[Region] ),
            ORDERBY ( CALCULATE ( SUM ( 'Sales data'[Sales Ach] ) ), DESC )
        )
)

(3) Then the result is as follows.

 

123abc_1-1701340688569.png

 

 

Best Regards,

Neeko Tang

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.