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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
123abc
Community Champion
Community Champion

Ranking for Main Category then furthermore 3 sub-categories based on %

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 ISSUE:

 Jihwan_Kim (The Super User of community) have solve the issue before and give solution but now a little bit change in design of dashboared therefore the below DAX measure is not work properly (when i used old below give DAX measure with New parameter command in Modeling Tab by filtered Region, Zone, Branhes and Area Sales Offier seperattarly (Pic attached) then Dax measure missed some rankings in Area sales officer and branches but region and zone is OK, i try to fix it but i no idea why this happen.)  ... please guide me how to solve hte issue:

Previous issue link: Solved: RANKX for Main Category then for furthermore 4 sub... - Microsoft Fabric Community

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

 

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

 

Dashboard Main WorkingDashboard Main WorkingExpected ResultsExpected Results

 Jihwan_Kim @Ashish_Mathur  @amitchandak

FreemanZ

 

 

 

 

 

2 ACCEPTED SOLUTIONS
Anonymous
Not applicable

Hi @123abc ,

 

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.

vtangjiemsft_0-1701310120527.pngvtangjiemsft_1-1701310131467.png

 

Best Regards,

Neeko Tang

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

View solution in original post

123abc
Community Champion
Community Champion

Thank YOu Very Mcuh, Its work in great manner. May God Bless You Amin.

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @123abc ,

 

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.

vtangjiemsft_0-1701310120527.pngvtangjiemsft_1-1701310131467.png

 

Best Regards,

Neeko Tang

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

123abc
Community Champion
Community Champion

Thank YOu Very Mcuh, Its work in great manner. May God Bless You Amin.

Helpful resources

Announcements
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.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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