Forum Discussion
RANKX and Slicing
I have a data set that includes "Name" and "Count" as a dimension table, and a fact table containing these Names and many Scores. I also have several Dim.Tables for various metrics, such as "Employee Classification". I have calculated average "Score" for each "Name" using a measure. I have created a ranking measure to rank the Names by the Scores:
Rank =
CALCULATE(
RANKX(
ALLSELECTED(Dim.Table[Name]),
[Avg Score],,desc,dense),
ALLSELECTED(Dim.Table2),
ALLSELECTED(Dim.Table3))
This gives me the results below:
| Name | Rank | Avg Measure |
| Employee 1 | 1 | 3.645 |
| Employee 2 | 1 | 3.645 |
| Employee 3 | 2 | 2.167 |
| Employee 4 | 2 | 2.167 |
| Employee 5 | 3 | 1.797 |
| Employee 6 | 4 | 0.871 |
| Employee 7 | 5 | 0.777 |
| Employee 8 | 6 | 0.762 |
| Employee 9 | 7 | 0.738 |
| Employee 10 | 8 | 0.724 |
| Employee 11 | 9 | 0.688 |
| Employee 12 | 9 | 0.688 |
| Employee 13 | 9 | 0.688 |
| Employee 14 | 9 | 0.688 |
| Employee 15 | 9 | 0.688 |
| Employee 16 | 10 | 0.631 |
| Employee 17 | 11 | 0.630 |
| Employee 18 | 12 | 0.594 |
| Employee 19 | 13 | 0.584 |
| Employee 20 | 14 | 0.536 |
This works as intended, and I have future measures that use tiebreakers which also works. However, when I add a slicer to the page for "Count", which is a calculated column in the Dim.Table, it changes the order of the ranking. The Count ranges from 0-22, and the slicer defaults to this range though none of the Employees have a Count of 0. When I move the slicer to a range of 1-22, the following happens:
Employees 1-15 remain the same, but Employee 16 and 17 swap Ranks. This also happens with several other Employees further down in the table:
| Employee 15 | 9 | 0.688 |
| Employee 17 | 11 | 0.630 |
| Employee 16 | 11 | 0.631 |
| Employee 18 | 12 | 0.594 |
| Employee 19 | 13 | 0.584 |
| Employee 20 | 14 | 0.536 |
Do we know why this is happening when the value it is ranking does not change?
DFPRO , explore new rank and row number function, that will give better options for tie-breaker using order by
Power BI - New DAX Function: RANK - How It Differs from RANKX: https://youtu.be/TjGkF44VtDo
Power BI - New DAX Function: Rownumber- https://www.youtube.com/watch?v=yS9-IQjUDwg&list=PLPaNVDMhUXGYo50Ajmr4SgSV9HIQLxc8L&index=1
If needed you can use dynamic segmentation
Dynamic Segmentation Bucketing Binning
https://community.powerbi.com/t5/Quick-Measures-Gallery/Dynamic-Segmentation-Bucketing-Binning/m-p/1387187#M626
Dynamic Segmentation, Bucketing or Binning: https://youtu.be/CuczXPj0N-k
2 Replies
- amitchandak
Super User
DFPRO , explore new rank and row number function, that will give better options for tie-breaker using order by
Power BI - New DAX Function: RANK - How It Differs from RANKX: https://youtu.be/TjGkF44VtDo
Power BI - New DAX Function: Rownumber- https://www.youtube.com/watch?v=yS9-IQjUDwg&list=PLPaNVDMhUXGYo50Ajmr4SgSV9HIQLxc8L&index=1
If needed you can use dynamic segmentation
Dynamic Segmentation Bucketing Binning
https://community.powerbi.com/t5/Quick-Measures-Gallery/Dynamic-Segmentation-Bucketing-Binning/m-p/1387187#M626
Dynamic Segmentation, Bucketing or Binning: https://youtu.be/CuczXPj0N-k- DFPROFrequent Visitor
Thank you, Amit. I recreated my first tie-breaking measure for Ranking by Name using Rownumber, then recreated all subsequent rank measures and it seems to work again. I don't know what broke it but thankful for the idea.