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
Anonymous
Not applicable

Dynamic TopN filter in Power BI

I have table contain only one column Title. Column values:
Title
Word 1
Word 4
Word 3
Word 1
Word 4
Word 2

How filter above table by dynamic TopN?

5 REPLIES 5
amitchandak
Super User
Super User

@Anonymous , Try like

Top 10 = CALCULATE([TotalTitle],TOPN(10,all('Content Catalog Search Result Report'[Title]),[TotalTitle],DESC),VALUES('Content Catalog Search Result Report'[Title]))

 

Here 10 can be variable or what if

Refer
https://community.powerbi.com/t5/Community-Blog/Dynamic-TopN-made-easy-with-What-If-Parameter/ba-p/367415

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
Anonymous
Not applicable

Thank you @amitchandak . But gives me duplicated Rank value for each duplicated count, see attach image.TopN.pngank v

Anonymous
Not applicable

Hi @Anonymous,

Any rules that you want to rank your field values? If you only want to choose rows based on it row_number, I'd like to suggest you add an index column to your table. Then you can filter on the index field values to show correspond records.

Create Index Columns Using Power Query 
Regards,

Xiaoxin Sheng

PaulDBrown
Community Champion
Community Champion

@Anonymous 

I'm not too sure what your dataset includes. Is it a single column listing "Word 1", "Word 4", "Word 3" etc as individual values, or do you have 2 columns (one for "Word" and another for a value? If the latter, does that mean that there is a single ID value for "Word"?

To calculate TopN you can use either TopN or RANKX for the measure, depending on what you wish to see. If by "dynamic TopN" you mean you wish to select the TopN using a slicer, you will need to create a independent table listing the rank values you wish to filter by.

Please also provide a depiction of what you wish to see in the visual.

 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






Anonymous
Not applicable

Yes. I have only single column in table with values  "Word 1", "Word 4", "Word 3", "Word 1" etc. All values are repetitive, so I calculate total count of each Word.
Here I'm using TopN slicer and then use RANKX to rank each words.
When I use rankx it returns 1 in each row.

TotalTitle = COUNT('Content Catalog Search Result Report'[Title])
Rank = RANKX(All('Content Catalog Search Result Report'[Title]),[TotalTitle], ,DESC)

 

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.