Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
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?
Solved! Go to Solution.
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/
Hi @Imagauthamam,
Thank you for posting your query in the Microsoft Fabric Community Forum, and thanks to @Deku, @andrewsommer & @danextian for sharing valuable insights.
Could you please confirm if your query has been resolved by the provided solution? If so, please mark it as the solution. This will help other community members solve similar problems faster.
Thank you.
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/
User | Count |
---|---|
76 | |
75 | |
46 | |
31 | |
27 |
User | Count |
---|---|
99 | |
91 | |
51 | |
49 | |
45 |