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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
v-jayw-msft
Community Support
Community Support

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.

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.

View solution in original post

4 REPLIES 4
v-jayw-msft
Community Support
Community Support

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.

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.

@v-jayw-msft 

 

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 ?

@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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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