Skip to main content

What are the differences between DAX functions Rank and Rankx?

Table of Contents

There is a significant difference between RANK and RANKX, and they should not be treated the same way as functions like SUM and SUMX.

RANK is similar to window functions and utilizes concepts like relationships, ordering, and partitioning, much like functions such as WINDOW, OFFSET, and INDEX. Released in April 2023, RANK is primarily suited for use in measures.

RANKX, on the other hand, is an older Power BI function that can be used with both columns and measures, making it more versatile.

Key Differences:
RANKX: This function 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.

Additional Points:
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.
While RANK is not a direct replacement for RANKX, it is the preferred choice going forward due to its improved handling of ties and blanks.

Add comment