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
mohammedkhan
Helper I
Helper I

Rank Selection Branches and Sub Branches

 

Dear All,

I have made Three Meaures and Rank Table where I enter the rank column value as 3 5 10 to use the Slicer as a top 3 to Top 10 Based on the Slicer selection, but when i select 3 it is showing 5 values as shown in the mention below image.

 

Rank Selection:

Rank Select = IF(HASONEVALUE('Rank Selection'[Ranks]), VALUES('Rank Selection'[Ranks]), 10000)
 
Game Ranking BY Game Income
Game Income Rank = RANKX(ALLSELECTED('Game Income'), [Total Game Income], , DESC)
 
Rank.JPG

 

 

 

2 ACCEPTED SOLUTIONS
jdbuchanan71
Super User
Super User

Hello @mohammedkhan 

You can skip the ranking and use TOPN with your ranking measure to get your TOPN games.  It would look something like this.

Top N Game Income =
VAR _Ranks =
    SELECTEDVALUE ( Ranks[Rank] )
VAR _RankingContext =
    VALUES ( 'Game Income'[Games] )
RETURN
    CALCULATE (
        [Total Game Income],
        TOPN ( _Ranks, ALL ( 'Game Income'[Games] ), [Total Game Income] ),
        _RankingContext
    )

Take a look at this video for more information on the example.

https://www.youtube.com/watch?v=bbM7JSQqn2I

View solution in original post

The problem you are running into is your ALL ( 'Games Income' ) is bringing the whole table, not just all the games.  What you want is this.

Game Rank = 
IF ( 
    NOT ISINSCOPE ( 'Game Income'[Games] ), BLANK(),
    RANKX ( ALL ( 'Game Income'[Games] ), [Total Game Income] )
)

And if you want the rank only on the TopN games you can use this.

TopN Game Rank = 
IF ( 
    ISBLANK ( [Top N Game Income] ) || NOT ISINSCOPE ( 'Game Income'[Games] ), BLANK(),
    RANKX ( ALL ( 'Game Income'[Games] ), [Top N Game Income] )
)

View solution in original post

5 REPLIES 5
jdbuchanan71
Super User
Super User

Hello @mohammedkhan 

You can skip the ranking and use TOPN with your ranking measure to get your TOPN games.  It would look something like this.

Top N Game Income =
VAR _Ranks =
    SELECTEDVALUE ( Ranks[Rank] )
VAR _RankingContext =
    VALUES ( 'Game Income'[Games] )
RETURN
    CALCULATE (
        [Total Game Income],
        TOPN ( _Ranks, ALL ( 'Game Income'[Games] ), [Total Game Income] ),
        _RankingContext
    )

Take a look at this video for more information on the example.

https://www.youtube.com/watch?v=bbM7JSQqn2I

Hi @jdbuchanan71 Could you please help on the Ranking as well, i would like to bring the Ranking accoridng to the Game Income but it is ranking absurd like 

firsst three games are 1 then 2

Game 1 Rank1

Game 2 Rank1

Game 3 Rank1

Game 4 Rank2

 

where is should be like 

 

Game 1 Rank 1 

Game 2 Rank 2 

Game 3 Rank 3

Game 4 Rank 4

You can also see that into that same image where the ranking for first three games is  1

 

Game Income Rank = RANKX(ALL('Game Income'), [Total Game Income], , DESC)

The problem you are running into is your ALL ( 'Games Income' ) is bringing the whole table, not just all the games.  What you want is this.

Game Rank = 
IF ( 
    NOT ISINSCOPE ( 'Game Income'[Games] ), BLANK(),
    RANKX ( ALL ( 'Game Income'[Games] ), [Total Game Income] )
)

And if you want the rank only on the TopN games you can use this.

TopN Game Rank = 
IF ( 
    ISBLANK ( [Top N Game Income] ) || NOT ISINSCOPE ( 'Game Income'[Games] ), BLANK(),
    RANKX ( ALL ( 'Game Income'[Games] ), [Top N Game Income] )
)

Thank you @jdbuchanan71 

Thank you @jdbuchanan71 this is a great help

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.