22.4 Top N Filter
Start with a problem
Shraddha wants only the top two stores by sales on a chart.
Explain simply
The Top N filter type keeps the top or bottom N items by a measure.
Show the data
| Store | City | Total Sales (₹) |
|---|---|---|
| Kothrud | Pune | 650 |
| College Road | Nashik | 500 |
| Rajarampuri | Kolhapur | 450 |
| Gangapur | Nashik | 300 |
| Baner | Pune | 200 |
About this data: This table uses columns: Store, City, Total Sales (₹). This table uses columns: Store, Total Sales (₹). This table uses columns: Wrong result, Reason, Correction. Values shown are the lesson examples already on this page (not a new dataset).
Fictional sample data. Practice file: visuals_orders_apr_may_2026.csv (source: src/practice/).
Demonstrate
- Store bar chart › Filters pane ›
Store› Filter type Top N. - Show items Top 2 › By value
Total Sales› Apply filter.
Show the result
Your result should look like this (fictional sample):
| Store | Total Sales (₹) |
|---|---|
| Kothrud | 650 |
| College Road | 500 |
Explain what happened
Power BI ranks stores by the measure and keeps the first two.
Explore further
- Dynamic N needs a parameter (21.5).
Detailed reference for this lesson:
Steps in Power BI – top 5 products in Nagpur
- Select a bar chart with
Product[Product Name]on the axis (City slicer = Nagpur). - In Filters on this visual, expand Product Name › Filter type › Top N.
- Show items: Top,
5. Drag[Total Sales]into By value › Apply filter. - Change the City slicer to Kolhapur. The top 5 are recalculated.
Lakshat theva, use Bottom to find the weakest products or slowest dark stores. For a user-controlled N, see Module 21.5.
Ravindra Bagale's Tip
Friends, remember: the Top N filter is evaluated in the visual's context, and students are surprised when the "Top 5 products" change with the City slicer. That is correct behaviour, so explain it in the title ("Top 5 products in selected city") or remove the slicer interaction if it should be fixed. Remember this rule.
Ravindra Bagale's Tip – मराठी
मित्रांनो, लक्षात ठेवा: Top N filter visual च्या context मध्ये evaluate होतो, आणि City slicer सोबत "Top 5 products" बदलले की students ना आश्चर्य वाटतं. हे बरोबरच वागणं आहे, म्हणून ते title मध्ये स्पष्ट करा ("Top 5 products in selected city") किंवा ते fixed हवं असेल तर slicer interaction काढून टाका. हा नियम लक्षात ठेवा.
Ravindra Bagale's Tip – हिंदी
दोस्तों, याद रखो: Top N filter visual के context में evaluate होता है, और City slicer के साथ "Top 5 products" बदलने पर students हैरान होते हैं. यह सही व्यवहार है, इसलिए title में समझा दो ("Top 5 products in selected city") या अगर इसे fixed रहना चाहिए तो slicer interaction हटा दो. यह नियम याद रखो.
Fix common mistakes
| Wrong result | Reason | Correction |
|---|---|---|
| Three stores shown | Tie at rank 2 | Expected with ties; add a tie-breaker measure |
| Top 2 overall, not per city | Top N is over the visual's items | Use RANKX per city for per-group Top N |
| Top N ignores slicer | It respects slicers – check interactions | Edit interactions |
Practise independently
Practice task
Change to Bottom 2.
Hints
- Smallest two.
Solution
Baner ₹200, Gangapur ₹300.
Think like a professional
State Top N in the title, or readers assume the chart shows everything.
Loading DAX practice tasks...
- Rank by Units (Hard): Shown per Reps Name. Measure: Units Rank = rank of [Total Units] among all Reps Name values.
- Top 3 only (Hard): Shown per Reps Name. Measure: Top 3 Units = [Total Units] when the rank is 3 or better, else blank.
- Units of the top 2 (Hard): Measure: Top 2 Units = [Total Units] for the 2 best Reps names.
- Total Units (Easy): Measure: Units Sum = SUM of Units.
- Share of Units (Medium): Shown per Reps Name. Measure: Units Share = SUM of Units ÷ SUM of Units for all of Reps.
- Return Rate (Medium): Shown per Reps Name. Measure: Return Rate = SUM of Returned ÷ SUM of Units.
- Only big reps (Medium): Shown per Reps Name. Measure: Big Units = [Total Units] when it is more than 8000, else blank.
- Rows per Rep (Easy): Shown per Reps Name. Measure: Row Count = number of RxSales rows.
- Units for Diabetes only (Medium): Shown per City. Measure: Units Diabetes = SUM of Units where Therapy is "Diabetes".
- Average Units per row (Medium): Shown per Reps Name. Measure: Units per Row = SUM of Units ÷ number of rows.
Revision card