Forum Discussion
Get nth value from a dataset
- 4 years ago
Ok, I see what you mean...
How about:
EDIT: Instead of creating the Rank for car in step 1 below, it will probably work using a much simpler:
1) Index for Rank =SUM(Table[car]) * 10000 + SUM(Table[Index])
which avoids needing two RANKX- you will need to take into account the number of rows for the *10000 = or make it really huge like * 1000000000
1) Create a measure combining car rank and index as follows:
Index for Rank = VAR _t = RANKX ( ALLSELECTED ( 'Table' ), [Sum car],, ASC, DENSE ) VAR _V = _t * 1000 + SUM ( 'Table'[index] ) RETURN _VNow the rank measure to use to choose the nth value:
Rank = RANKX(ALLSELECTED('Table'), [Index for Rank], ,ASC,Dense)New file attached
- 4 years ago
Correct!
but use the method
Index for Rank =SUM(Table[car]) * 100000000000 + SUM(Table[Index])
as the first step (to avoid using the costly RANKX), and then use RANKX over this [Index for Rank].
In theory, using the car value * 10000000000 "provides" the correct order; adding the index makes each value unique.
Anonymous , Try if Rank tie breaker can help
Rank Tie breaker
https://community.powerbi.com/t5/Community-Blog/Breaking-Ties-in-Rankings-with-RANKX-Using-Multiple-Columns/ba-p/918655
https://databear.com/how-to-use-the-dax-rankx-function-in-power-bi/
amitchandak unfortunately, it doesn't. For example, in the scenario, I've mentioned, these would be the ranks for Skip and Dense options.
| value | rank.Skip | rank.Dense |
| 1 | 1 | 1 |
| 2 | 2 | 2 |
| 2 | 2 | 2 |
| 3 | 4 | 3 |
| 3 | 4 | 3 |
| 3 | 4 | 3 |
| 4 | 7 | 4 |
| 5 | 8 | 5 |
| 5 | 8 | 5 |
| 6 | 10 | 6 |
| 7 | 11 | 7 |
| 8 | 12 | 8 |