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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
Moonc
Frequent Visitor

Getting RANKX to rank parent only in matrix

I have a matrix with a grouping and a subgrouping and then a measure in values that is summing. I have a measure that ranks both the Grouping and the Subgrouping independently of each other

Example: https://imgur.com/crq9cxw

I have this logic working fine, no issues

I want to figure out how to give the rank of the top level group to the values in the sub group. It seems like whenever I rank just the top level group, the ranks for the subgroups just repeat 1.

Example: https://imgur.com/MCyMCiZ

Any ideas?

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Moonc ,

 

Here I create a sample to have a test and I hope it could help you.

vrzhoumsft_0-1693211462536.png

Measure:

Measure = CALCULATE(SUM('Table'[Value]))
Rank = 
VAR _SUMMARIZE =
    SUMMARIZE (
        ALL ( 'Table' ),
        'Table'[Group],
        "Sum by Group", CALCULATE ( SUM ( 'Table'[Value] ), ALLEXCEPT ( 'Table', 'Table'[Group] ) )
    )
VAR _RANK =
    ADDCOLUMNS (
        _SUMMARIZE,
        "Rank", RANKX ( _SUMMARIZE, [Sum by Group],, ASC, DENSE )
    )
RETURN
    MAXX ( FILTER ( _RANK, [Group] = MAX ( 'Table'[Group] ) ), [Rank] )

Result is as below.

vrzhoumsft_2-1693211500427.png

 

Best Regards,

Rico Zhou

 

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

2 REPLIES 2
Moonc
Frequent Visitor

Added clarity. If I just do a RANKX for the main grouping (A/B/C) and put it in the matrix, I get this: https://imgur.com/pDYfFDD.

 

In this scenario, I want the 1s to be the rank of their parent.

Anonymous
Not applicable

Hi @Moonc ,

 

Here I create a sample to have a test and I hope it could help you.

vrzhoumsft_0-1693211462536.png

Measure:

Measure = CALCULATE(SUM('Table'[Value]))
Rank = 
VAR _SUMMARIZE =
    SUMMARIZE (
        ALL ( 'Table' ),
        'Table'[Group],
        "Sum by Group", CALCULATE ( SUM ( 'Table'[Value] ), ALLEXCEPT ( 'Table', 'Table'[Group] ) )
    )
VAR _RANK =
    ADDCOLUMNS (
        _SUMMARIZE,
        "Rank", RANKX ( _SUMMARIZE, [Sum by Group],, ASC, DENSE )
    )
RETURN
    MAXX ( FILTER ( _RANK, [Group] = MAX ( 'Table'[Group] ) ), [Rank] )

Result is as below.

vrzhoumsft_2-1693211500427.png

 

Best Regards,

Rico Zhou

 

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

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.