Forum Discussion
RankX - Unique ranking for Duplicate Values
- 2 years ago
ViralPatel212 , use new rank or rownumber function
Rank
RANK(DENSE, ALLSELECTED(cp[counter_party]),ORDERBY([Ranking Size (Vol)],DESC,[counter_party]) )
Rownumber
ROWNUMBER(ALLSELECTED(cp[counter_party]),ORDERBY([Ranking Size (Vol)],DESC))
Power BI - New DAX Function: RANK - How It Differs from RANKX: https://youtu.be/TjGkF44VtDo
Rownumber- https://www.youtube.com/watch?v=yS9-IQjUDwg&list=PLPaNVDMhUXGYo50Ajmr4SgSV9HIQLxc8L&index=1
To ensure each dealer has a unique rank, you can use the RANKX function with the DENSE ranking method and add a tie-breaking condition. Here’s an updated version of your DAX measure:
Dealer Ranking Number =
VAR _volume = [Ranking Size (Vol)]
RETURN
IF(
ISBLANK(_volume),
BLANK(),
RANKX(
ALLSELECTED(cp[counter_party]),
_volume,
,
DESC,
DENSE
) +
RANKX(
ALLSELECTED(cp[counter_party]),
cp[counter_party],
,
ASC,
DENSE
) / 1000
)
In this measure:
- The first RANKX function ranks the dealers based on their volume in descending order.
- The second RANKX function adds a small fractional value based on the alphabetical order of the dealer names to break ties.
This should give each dealer a unique rank. Replace cp[counter_party] and [Ranking Size (Vol)] with the actual column names in your table.
Thanks!