Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Samruddhi_11
Helper I
Helper I

Not working: Top N functionality (TOP N by "count" column if the count is repetitive)

Hii,

 

Samruddhi_11_0-1641901800985.png

As I shown in the above image, TOP N is not working. 
Explaination : There are 2 columns in my visual. 1. Pin name and 2. Count of pins. I want top 5 pin's by count of pins. here I applied filter on TOP N by count of pins but its not working. Its only giving me pins having 11 as a count which is max count. 11 count is repetative in this visual. There are other counts as well like 2, 4, 7 and 9 which are repetative but not showing rows with those counts in visual. Please help me in resolving this.
Thanks in advance!

1 ACCEPTED SOLUTION
v-yalanwu-msft
Community Support
Community Support

Hi, @Samruddhi_11 ;

As far as I know, topn is to display the first few, first if you set topn5, then count=11 is the largest sort, but count=11 name is more than 5, then topn5 only display count=11;

For example, if you have four rows count=11 and two rows count=10, then topn5 displays six rows, Anyway, it's counting repeating columns.

 

so we could create a mesure.

rank = RANKX(ALLSELECTED('Table'),CALCULATE( COUNT('Table'[name])),,DESC,Dense)

Then could set less than or equal to .

vyalanwumsft_1-1642140203643.png

 

The final output is shown below:

vyalanwumsft_2-1642140241075.png


Best Regards,
Community Support Team_ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

9 REPLIES 9
v-yalanwu-msft
Community Support
Community Support

Hi, @Samruddhi_11 ;

As far as I know, topn is to display the first few, first if you set topn5, then count=11 is the largest sort, but count=11 name is more than 5, then topn5 only display count=11;

For example, if you have four rows count=11 and two rows count=10, then topn5 displays six rows, Anyway, it's counting repeating columns.

 

so we could create a mesure.

rank = RANKX(ALLSELECTED('Table'),CALCULATE( COUNT('Table'[name])),,DESC,Dense)

Then could set less than or equal to .

vyalanwumsft_1-1642140203643.png

 

The final output is shown below:

vyalanwumsft_2-1642140241075.png


Best Regards,
Community Support Team_ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@v-yalanwu-msft  Thank you!

amitchandak
Super User
Super User

@Samruddhi_11 , based on what I got. Create a dense rank and use that in the filter in visual level filter for <= 5

 

rankx(allselected(Table[Pin name]), [Count of pin measure],,desc, dense ) 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Hi @amitchandak , 
Thank you for your valuable solution but getting one problem if I select top 3 then only those rows are coming having count 2 and 4 . after 4 it should display rows with 7 count but its not showing so its not working for top 3 , 4 and 5. please help me in this. 

I attached 2 screenshots after applying top 3 in filter:

1. Ascending of count

Samruddhi_11_0-1641908065487.png

2. Descending of count

Samruddhi_11_1-1641908103197.png

Written Measure2 as you mentioned
Thanks!!

@Samruddhi_11 , can you share the measure. Also make sure in rank you have used measure, not just count(Table[Column]) , if you have used that then use calculate(count(Table[Column]))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Hi @amitchandak ,

Below is a measure,

Measure2 =
RANKX(ALLSELECTED(cloud_pricing_export[sku]), cloud_pricing_export[Count of sku],,DESC,Dense)
where ,
cloud_pricing_export = table name
sku = pin name
count of sku = measure
Formula: 
Count of sku =
COUNT(cloud_pricing_export[sku])

@Samruddhi_11  can be resolved a lot quicker, if you can provide sample data and expected output.

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

I am not able to attach data file.

There are 2 columns pin name and count of pins. I want top 5 pin names by count of pins. The only problem here is TOPN functionality of power BI is not working because the counts are repetative. if you have any query please do ask. Thanks!

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.