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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Stemar_Aubert
Resolver I
Resolver I

RANKX values while excluding some items, with a twist.

Hello,

 

I have the following measure:

 

EyzRank =
SWITCH (
    ISBLANK ( 'Actual'[YTD 19] ),
    FALSE (), RANKX ( ALLSELECTED ( Reps[INDUSTRY REP] ), 'Actual'[YTD 19] ),
    BLANK ()
)

 

 It will rank the sales people based on actuals YTD. The ALLSELECTED is here because when regional managers have the report, they must be able change the ranking selection between world or their region. The SWITCH() is present because I will have multiple ranking methods based on other metrics, but the issue I have is with ALLSELECTED.

 

B5cavwx

When deployed in a table, it works. Trouble is, I need to cut the top 3 individual from this list. And of course, because of ALLSELECTED, I have the following result when I apply a filter:

hzI828G

 

As you can see, I now only have 19 sales people, but RANKX doesn't behave like I need (though it behave as expected).

Ideal output here would be as follow :

4T47.2%
5F46.4%
6Z44.8%
7J44.4%
.........

 

Can you provide insights on this ? I need to be able able to filter by Region (and other slicers), but must be able to exclude the top 3 items. Thank you.

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Stemar_Aubert ,

 

You can try add conditions before using RANKX().

Please refer to the formula below.

 

 

Measure 2 =
IF (
    ISFILTERED ( 'Table'[region] ),
    RANKX (
        FILTER ( ALL ( 'Table' ), 'Table'[region] = SELECTEDVALUE ( 'Table'[region] ) ),
        [Measure],
        ,
        ASC
    ),
    RANKX ( ALL ( 'Table' ), [Measure],, ASC )
)

 

 

Result would be shown as below.

2.PNG

3.PNG

4.PNG

 

Best Regards,

Jay

Community Support Team _ Jay Wang

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
Anonymous
Not applicable

Hi @Stemar_Aubert ,

 

You can try add conditions before using RANKX().

Please refer to the formula below.

 

 

Measure 2 =
IF (
    ISFILTERED ( 'Table'[region] ),
    RANKX (
        FILTER ( ALL ( 'Table' ), 'Table'[region] = SELECTEDVALUE ( 'Table'[region] ) ),
        [Measure],
        ,
        ASC
    ),
    RANKX ( ALL ( 'Table' ), [Measure],, ASC )
)

 

 

Result would be shown as below.

2.PNG

3.PNG

4.PNG

 

Best Regards,

Jay

Community Support Team _ Jay Wang

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

@Anonymous 

 

Thank you for the help. At first it didn't work because I have data in multiple tables. However, using the logic you've provided, I got it working.

EyzRank =
SWITCH (
    ISCROSSFILTERED ( Location[REGION] ),
    FALSE (), IF (
        ISBLANK ( ( 'Actual'[actuals YTD 19] ) ),
        BLANK (),
        CALCULATE (
            RANKX ( ALL ( Reps[INDUSTRY REP] ), 'Actual'[actuals YTD 19] ),
            FILTER (
                ALL ( Location[REGION] ),
                Location[REGION] = SELECTEDVALUE ( Location[REGION] )
            )
        )
    ),
    IF (
        ISBLANK ( ( 'Actual'[actuals YTD 19] ) ),
        BLANK (),
        CALCULATE ( RANKX ( ALL ( Reps[INDUSTRY REP] ), 'Actual'[actuals YTD 19] ) )
    )
)

 

I use ISCROSSFILTERED because my regional selection is done through a map visual, not a slicer.

The whole measure is not the most elegant solution at the moment, but I can now work to integrate the other parts.

amitchandak
Super User
Super User

When you simply use

RANKX ( ALLSELECTED ( Reps[INDUSTRY REP] ), 'Actual'[YTD 19] )

 

Will, it will not give the expected result. As the measure will not rank beyond 19 ?

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

@amitchandak  Hi,

 

The switch wrapping the ranking formula doesn't impact the issue. The problem is simply that I must "cut" the top 3 results, but also have the RANKX formula calculate the set based on regionaly-filtred context.

 

Thanks

 

 

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors