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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
BlueWhite3699
Helper II
Helper II

RANKX as a calculated column DAX measure

Hi Experts

 

How would you rank the following using a calculated column formula. See sample data

 

ScoreDepartmentRanking
10Training3
11Training2
15Training1
22Consultancy3
27Consultancy2
30Consultancy1
1Sales1
2Sales2
11Marketing2
12Marketing1
1 ACCEPTED SOLUTION
mdaatifraza5556
Solution Supplier
Solution Supplier

Hi @BlueWhite3699 

Can you please try the below DAX ?

Ranking =
RANKX(
    FILTER(
        'Tables',
        Tables[Department] = EARLIER(Tables[Department])
    ),
    Tables[Score],
    ,
    DESC,
    DENSE
)
 
 
Screenshot 2025-05-08 150601.png

 

 
If this answers your questions, kindly accept it as a solution and give kudos.

View solution in original post

4 REPLIES 4
v-priyankata
Community Support
Community Support

Hi @BlueWhite3699 

May I ask if you have resolved this issue? If so, please mark the helpful reply and accept it as the solution. This will be helpful for other community members who have similar problems to solve it faster.

Thank you.

AntrikshSharma
Super User
Super User

@BlueWhite3699 Ranking for sales is wrong in your example, you can use any of these.

 

Ranking = 
RANK ( 
    DENSE, 
    ALL ( DepartmentScores[Score], DepartmentScores[Department] ), 
    ORDERBY ( DepartmentScores[Score], DESC ), 
    PARTITIONBY ( DepartmentScores[Department] ) 
)

 

Ranking = 
VAR CurrentScore = 
    DepartmentScores[Score]
RETURN
    CALCULATE ( 
        COUNTROWS ( DepartmentScores ),
        REMOVEFILTERS ( DepartmentScores[Score] ),
        DepartmentScores[Score] >= CurrentScore
    )

 

Ranking = 
VAR CurrentScore = 
    DepartmentScores[Score]
VAR CurrentDepartment = 
    DepartmentScores[Department]
VAR Result = 
    COUNTROWS ( 
        FILTER ( 
            DepartmentScores, 
            DepartmentScores[Department] = CurrentDepartment 
                && DepartmentScores[Score] >= CurrentScore 
        )
    )
RETURN
    Result
Shivu-2000
Super User
Super User

Hii @BlueWhite3699,

I recommend first trying the solution provided by @mdaatifraza5556 .

If the issue still persists, here is a slightly modified version that might help resolve it.

Ranking =
CALCULATE(
COUNTROWS('Table'),
FILTER(
'Table',
'Table'[Department] = EARLIER('Table'[Department])
&& 'Table'[Score] > EARLIER('Table'[Score])
)
) + 1

 

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

mdaatifraza5556
Solution Supplier
Solution Supplier

Hi @BlueWhite3699 

Can you please try the below DAX ?

Ranking =
RANKX(
    FILTER(
        'Tables',
        Tables[Department] = EARLIER(Tables[Department])
    ),
    Tables[Score],
    ,
    DESC,
    DENSE
)
 
 
Screenshot 2025-05-08 150601.png

 

 
If this answers your questions, kindly accept it as a solution and give kudos.

Helpful resources

Announcements
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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