Forum Discussion
Arshadjehan
6 years agoHelper I
Count of records Based on RANKX
I have dynamically filtered the based based on a slicer options of: Top 3, Top 5 and Top 10. I want to display number of records filtered , e.g when I select Top 3 , records returned after RANKX fun...
- 6 years ago
Arshadjehan - Given the form of that RANKX calculation it must be a calculated column. Therefore, this should be something like the following:
Male = COUNTROWS(FILTER('Table',[Top N] <= 3 && [Gender]="M")) Female = COUNTROWS(FILTER('Table',[Top N] <= 3 && [Gender]="F"))
Arshadjehan
6 years agoHelper I
Greg_Deckler That worked like a charm! Thanks man.
Just one thing needed: Since I am using Dense parameter in RANKX function , so i am having ties in the result. How can I add sequential serial number in the table vaisual as below:
| Serial No | Position | Name | Marks |
| 1 | 1 | ABC | 545 |
| 2 | 2 | DEF | 535 |
| 3 | 2 | GEF | 535 |
| 4 | 3 | LMO | 525 |
| 5 | 3 | XYZ | 525 |
Greg_Deckler
6 years agoCommunity Champion
Arshadjehan - So, generally adding an index in DAX is considered impossible. However, there is a method for doing it.
https://community.powerbi.com/t5/Quick-Measures-Gallery/The-Mythical-DAX-Index/m-p/1093214#M528
The other way would be to add a tiny random number to your rank/topn calculation
Top N = RANKX(ALLSELECTED('tblResult'),[Marks],,,Dense) + RANDBETWEEN(.001,.009)
and then you could have a column:
Index = COUNTROWS(FILTER('Table',[Top N]<=EARLIER([Top N])))
This will, in effect break your ties.