Forum Discussion
only show the first 15 rows
I have this table and I am wanting to only show the top 15 rows based on the Qty sold. I have some visual level fitlers applied to remove a couple unwanted rows. A little stumped on how to get this one. essentially I want a report on the top 15 items sold that day. I do not have an option for top N on Qty sold
Hi Anonymous ,
Since the "Top N" filter isn't available in your case, you can achieve the desired result by using a combination of ranking with DAX measures and visual-level filters. Here’s a complete solution to dynamically filter your table visual to show only the top 15 items by Qty Sold for a selected day.
First, create a DAX measure to rank the items based on their total Qty Sold:
Rank by Qty Sold = RANKX( FILTER( ALL('Table'[Item Name]), CALCULATE(SUM('Table'[Qty Sold])) > 0 ), CALCULATE(SUM('Table'[Qty Sold])), , DESC, DENSE )This measure ranks the items in descending order of Qty Sold, ensuring that only items with sales greater than zero are included.
Next, create a second DAX measure to filter the top 15 items:
Top 15 Filter = IF([Rank by Qty Sold] <= 15, 1, 0)This measure returns 1 if an item is ranked within the top 15 and 0 otherwise.
Apply this measure as a visual-level filter in your table visual:
- Go to the "Filters on this visual" pane.
- Drag the Top 15 Filter measure to the filters area.
- Set the filter condition to "is equal to 1."
This method will ensure that your table visual dynamically shows only the top 15 items by Qty Sold, even if the "Top N" option is not available directly in your filters.
If you have a date slicer applied, the ranking will automatically adjust to show the top 15 items for the selected date. If needed, ensure that your DAX calculations respect any date filter context by wrapping the measure inside a CALCULATE function with date filters.
Best regards,
5 Replies
- DataNinja777
Super User
Hi Anonymous ,
Since the "Top N" filter isn't available in your case, you can achieve the desired result by using a combination of ranking with DAX measures and visual-level filters. Here’s a complete solution to dynamically filter your table visual to show only the top 15 items by Qty Sold for a selected day.
First, create a DAX measure to rank the items based on their total Qty Sold:
Rank by Qty Sold = RANKX( FILTER( ALL('Table'[Item Name]), CALCULATE(SUM('Table'[Qty Sold])) > 0 ), CALCULATE(SUM('Table'[Qty Sold])), , DESC, DENSE )This measure ranks the items in descending order of Qty Sold, ensuring that only items with sales greater than zero are included.
Next, create a second DAX measure to filter the top 15 items:
Top 15 Filter = IF([Rank by Qty Sold] <= 15, 1, 0)This measure returns 1 if an item is ranked within the top 15 and 0 otherwise.
Apply this measure as a visual-level filter in your table visual:
- Go to the "Filters on this visual" pane.
- Drag the Top 15 Filter measure to the filters area.
- Set the filter condition to "is equal to 1."
This method will ensure that your table visual dynamically shows only the top 15 items by Qty Sold, even if the "Top N" option is not available directly in your filters.
If you have a date slicer applied, the ranking will automatically adjust to show the top 15 items for the selected date. If needed, ensure that your DAX calculations respect any date filter context by wrapping the measure inside a CALCULATE function with date filters.
Best regards,
- Ashish_Mathur
Super User
Hi,
You may create a Rank measure and the filter that measure with the criteria of <=15.
Hope this helps.
- anmolmalviya05
Super User
Hi Anonymous, Hope you are doing good.
Power BI has recently introduced the new data limit feature at visual level. You can check it out.
You can refer to below content:
Blog: https://numlytics.com/blog/f/power-bi%E2%80%99s-new-data-limit-feature
Video: https://www.youtube.com/watch?v=IHfQ6MexoDUDid I answer your question? Mark my post as a solution! Appreciate your Kudos !!
Let's Connect on LinkedIn: https://www.linkedin.com/in/anmol-malviya/?originalSubdomain=in
Subscribe my youtube channel for Microsoft Fabric and Power BI updates: https://www.youtube.com/@AnmolPowerBICorner
- lbendlin
Super User
I do not have an option for top N on Qty soldwhy not?
RANKX and TOPN are pretty much the same thing.
- AnonymousNot applicable
Hi, Anonymous
May I ask if you have gotten this issue resolved? If it is solved, please share your solution and accept it as solution, it will be helpful for other members of the community who have similar problems as yours to solve it faster.
If it is not resolved, I hope you will provide the full .pbix file via OneDrive or SharePoint. Please be careful to remove all sensitive information and we will do our best to provide ideas for your issue.I hope my suggestions give you good ideas, if you have any more questions, please clarify in a follow-up reply.
Best Regards,
Fen Ling,
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.