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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
yakovlol
Resolver I
Resolver I

Show rank (Rankx) for user within 1 month with the same value

Hello team,

 

I have an issue with ranking in my table and cannot solve the issue

So I have a table like the one below. 

 

Full name Project name Date Hours   RANK How it calculated now   Desired RANK
User 1DDDDDD2/1/2023   32     2     3
User 1AAAAAA2/1/2023  100     1     1
User 1BBBBBBB2/1/2023  100     1     2

 

I have created a calculated column that calculates the rank within a month for each value. However, when the values are the same, the same rank number appears. I want the rank to be determined based on the project name in ascending order, if users have the same value within one month, like the 'Desired RANK' column shown in the example.

 

 

Ranks = 
VAR ThisMonth = 'My table'[Date_]
VAR user = 'My table'[Full name]
RETURN
    RANKX(
        FILTER(
            ALL('My table'),
           'My table'[Date_] = ThisMonth &&
           'My table'[Full name] = user
        ),
        [hours], ,
        DESC, 
        Dense
    )

 

Maybe there is a way to fix it.

 

Thank you

2 ACCEPTED SOLUTIONS
Ahmedx
Super User
Super User

Share sample pbix file to help you.

View solution in original post

Hello @Ahmedx 

I found solution. So yeah I added Index column in PQ, before that I've sorted Project_name ASC.

Than modified my formula and seems it works now, and for dublicated values rank is set correct

Ranks = 
VAR ThisMonth = 'My table'[Date_]
VAR user = 'My table'[Full name]
RETURN
    RANKX(
        FILTER(
            'My table',
            'My table'[Date_] = ThisMonth &&
            'My table'[Full name] = user
        ),
        'My table'[hours] - [Index] / POWER ( 10, 9 ),,
        DESC, 
        Dense
    )

 

View solution in original post

9 REPLIES 9
Ahmedx
Super User
Super User

pls try this

Screenshot_7.png

 

Ranks = 
VAR ThisMonth = 'My table'[Date_]
VAR user = 'My table'[Full name]
RETURN
    RANKX(
        FILTER(
            ALL('My table'),
           'My table'[Date_] = ThisMonth &&
           'My table'[Full name] = user
        ),
        [hours]& [ Project name], ,
        DESC, 
        Dense
    )

 

 

Hello @Ahmedx thank you for your approach. But now it's ranking based on text but not the hours values.

It's not shown on the example, but if we add another User 2, and put for him different Hours values and will be ranked based on Text, so in alphabetical order  because of this part  in our formula (hours & project name)

Full nameProject nameDateHoursHow its calculated now
User 2BBBBBBB2/1/2023  101  1
User 2AAAAAA2/1/2023  102  2

you can add column index ( in power query)?

Hello @Ahmedx 

I found solution. So yeah I added Index column in PQ, before that I've sorted Project_name ASC.

Than modified my formula and seems it works now, and for dublicated values rank is set correct

Ranks = 
VAR ThisMonth = 'My table'[Date_]
VAR user = 'My table'[Full name]
RETURN
    RANKX(
        FILTER(
            'My table',
            'My table'[Date_] = ThisMonth &&
            'My table'[Full name] = user
        ),
        'My table'[hours] - [Index] / POWER ( 10, 9 ),,
        DESC, 
        Dense
    )

 

Ahmedx
Super User
Super User

Share sample pbix file to help you.

Ahmedx
Super User
Super User

and try this

Ranks = 
VAR ThisMonth = 'My table'[Date_]
VAR user = 'My table'[Full name]
RETURN
    RANKX(
        FILTER(
            ALL('My table'),
           'My table'[Date_] = ThisMonth &&
           'My table'[Full name] = user
        ),
        [hours],[Project name] ,
        DESC, 
        Dense
    )

Hello @Ahmedx thanks for your answer
but now I'm faced with such an error "Function 'RANKX' does not support comparing values of type Number with values of type Text. Consider using the VALUE or FORMAT function to convert one of the values"

Ahmedx
Super User
Super User

pls try this

Ranks = 
VAR ThisMonth = 'My table'[Date_]
VAR user = 'My table'[Full name]
RETURN
    RANKX(
        FILTER(
            ALL('My table'),
           'My table'[Date_] = ThisMonth &&
           'My table'[Full name] = user
        ),
        [hours]+ (RANDBETWEEN(1 , 1E18)/1E18) , ,
        DESC, 
        Dense
    )

Thank you for the reply. I tried to use this, but now, this calculation misses Rank 1, and started from 2, but the same rank for the same values, unfortunately.

so after this calculation i have rank number as below

 

Full nameProject nameDateHoursHow its calculated now
User 1DDDDDD2/1/2023  32  3
User 1AAAAAA2/1/2023  100  2
User 1BBBBBBB2/1/2023  100  2

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors