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
Chris_23
Helper II
Helper II

RANKX Measure should ignoring Higher-Level Context for Independent Ranking

Hello everyone,

 

I have an issue with a RANKX measure. I want to create a ranking on the second level based on a measure, and this works well (1) for only two Levels: [Name] and [Supervisor]:

 

Rank1 =

  CALCULATE(
    RANKX(
        Filter(ALLSELECTED(Master[Name]), Not(ISBLANK([Sum]))),  
        [Sum],
        ,
        ASC
    ),
    REMOVEFILTERS(Master[Supervisor])
    )

 

Chris_23_0-1730729279833.png

 

However, when I add a higher level (Region), the ranking on the second (Name) level is created within the context of the first level (2) even with Removefilters on Region:

CALCULATE(
    RANKX(
        Filter(ALLSELECTED(Master[Name]), Not(ISBLANK([Sum]))),  
        [Sum],
        ,
        ASC
    ),
    REMOVEFILTERS(Master[Supervisor]),
    REMOVEFILTERS(Master[Region])
)

 

What I want instead is for this column to ignore the highest level and have the ranking remain independent of the Region.

RankX_3Level.pbix

 

Thank you very much for your help!

Chris

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Chris_23 

 

Please try this:

 

Rank2 =
VAR _vtable =
    VAR _vtable =
        SUMMARIZE (
            FILTER ( ALLSELECTED ( 'Master' ), 'Master'[Sum] <> BLANK () ),
            Master[Name],
            "_SUM", [Sum]
        )
    RETURN
        ADDCOLUMNS ( _vtable, "_rankx", RANKX ( _vtable, [_SUM],, ASC ) )
VAR _currentName =
    SELECTEDVALUE ( Master[Name] )
RETURN
    IF (
        ISINSCOPE ( Master[Name] ),
        MAXX ( FILTER ( _vtable, 'Master'[Name] = _currentName ), [_rankx] )
    )

 

The result is as follow:

vzhengdxumsft_0-1730856926896.png

 

 

Best Regards

Zhengdong Xu
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

4 REPLIES 4
Chris_23
Helper II
Helper II

Hi @Anonymous 

 

thanks for your response.

However, that’s not quite the result I’m aiming for.

Ultimately, I’d like to achieve a ranking that is independent of the first level, Region:

 

Chris_23_0-1730794241839.png

 

 

Kind regards

Chris

Anonymous
Not applicable

Hi @Chris_23 

 

Please try this:

 

Rank2 =
VAR _vtable =
    VAR _vtable =
        SUMMARIZE (
            FILTER ( ALLSELECTED ( 'Master' ), 'Master'[Sum] <> BLANK () ),
            Master[Name],
            "_SUM", [Sum]
        )
    RETURN
        ADDCOLUMNS ( _vtable, "_rankx", RANKX ( _vtable, [_SUM],, ASC ) )
VAR _currentName =
    SELECTEDVALUE ( Master[Name] )
RETURN
    IF (
        ISINSCOPE ( Master[Name] ),
        MAXX ( FILTER ( _vtable, 'Master'[Name] = _currentName ), [_rankx] )
    )

 

The result is as follow:

vzhengdxumsft_0-1730856926896.png

 

 

Best Regards

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

Thank you very much for the great solution

Anonymous
Not applicable

Hi @Chris_23 

 

You can change the [Rank2] like this:

IF ( ISINSCOPE ( Master[Name] ), [Rank1] )

The ISINSCOPE() returns true when the specified column is the level in a hierarchy of levels.

You can refer to this:

ISINSCOPE function (DAX) - DAX | Microsoft Learn

 

The result is as follow:

vzhengdxumsft_0-1730773706678.png

 

Best Regards

Zhengdong Xu
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.

FabCon and SQLCon Highlights Carousel

FabCon &SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.

March Power BI Update Carousel

Power BI Community Update - March 2026

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