Forum Discussion
How to create a rank column with only distinct numbers? +RAND() is not working.
- 3 years ago
Hello Yiyi
Using RANX with RAND() in this way is not reliable.
RANKX works by determining the position of the current value "within" the list of values computed for each row of the table.
Using your existing expression, RAND() will be added to both the "current" value and the values per row of the table independently, which will inevitably result in ranks that occur between the values corresponding to rows of the table.
I would instead suggest using RANK, which can use the Media column to break ties.
Change the RANKX expression to:
RANK ( DENSE, _t, ORDERBY ( [Unique_Item_Count], DESC, 'Main Data'[Media], ASC ), DEFAULT )Does this work for you?
Regards
Hello Yiyi
Using RANX with RAND() in this way is not reliable.
RANKX works by determining the position of the current value "within" the list of values computed for each row of the table.
Using your existing expression, RAND() will be added to both the "current" value and the values per row of the table independently, which will inevitably result in ranks that occur between the values corresponding to rows of the table.
I would instead suggest using RANK, which can use the Media column to break ties.
Change the RANKX expression to:
RANK (
DENSE,
_t,
ORDERBY ( [Unique_Item_Count], DESC, 'Main Data'[Media], ASC ),
DEFAULT
)
Does this work for you?
Regards
- Yiyi3 years ago
Helper I
It works perfectly. Thanks so much for your time 😊