Forum Discussion
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 function may be 3 or more based on ties (I have used Dense option in RANKX) . So how can I show count of records on a card?
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"))
6 Replies
- Greg_Deckler
Community Champion
Arshadjehan - I would think you should just be able to use:
Measure = COUNTROWS('Table')Not really enough information to go on, please first check if your issue is a common issue listed here: https://community.powerbi.com/t5/Community-Blog/Before-You-Post-Read-This/ba-p/1116882
Also, please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490
The most important parts are:
1. Sample data as text, use the table tool in the editing bar
2. Expected output from sample data
3. Explanation in words of how to get from 1. to 2.- Arshadjehan
Helper I
Here is the sample data: tblResults
Auto ID Roll No Name Marks Gender 1 12324 ABC 515 M 2 2323 LMN 525 M 3 23234 XYN 535 F 4 65655 DEF 525 M 5 345345 PRS 510 F ............. Table has more than a million records.
As a first step I have to list only Top 3, Top 5 or Top 10 records
I am doing that by applying RANKX function as below:
Top N = RANKX(ALLSELECTED('tblResult'),[Marks],,,Dense)I am getting the result for Top 3 in table visual as :Rank Roll No Name Marks Gender 3 12324 ABC 515 M 2 2323 LMN 525 M 1 23234 XYN 535 F 2 65655 DEF 525 M Next I want to display number of student from Top N being Male or female on card visual as:
Male: 3
Female:1
Hope I have elobarated well now
- Greg_Deckler
Community Champion
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"))
- amitchandak
Super User