Microsoft Fabric Community Conference 2025, March 31 - April 2, Las Vegas, Nevada. Use code FABINSIDER for a $400 discount.
Register nowThe Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.
Hi All,
I'm currently learning RANK and RANKX Dax functions.
Can someone explain the difference between these 2 functions and on what scenarios you use each of these DAX functions.
Is there something which is possible in one but not possible in the other and which you do you use most and why?
RANKX came out first.
RANK was introducted with all other window functions to support visual calculations
I think this is one a lot of people struggle with. There is a significant difference between these two unlike SUM and SUMX that are somewhat similar.
RANKX: calculates the rank of a value among all possible values derived from the evaluation of an expression across all rows in a table. It provides a rank number based on evaluating the expression for each row, with the default sort order being descending.
RANK: In contrast, RANK returns the ranking for the current context within a specified partition, sorted by the specified order. If no match is found, the rank is returned as blank. The default sort order for RANK is ascending.
When used in a measure, RANKX cannot use a column to define the rank order in the expression, while RANK can.
RANK is preferred over RANKX when it comes to handling ties and sorting blanks.
We almost always use RANK and rarely ever use RANKX
RANK function makes ranking on multiple columns much simpler as it allows sorting by multiple columns as a native feature. Doing this with RANKX will require some DAX acrobatics. This blog from SQLBI explains the difference quite well and also provides some examples - https://www.sqlbi.com/articles/introducing-the-rank-window-function-in-dax/