Ravindra BagaleCourses & study guides मराठी Track your progress

22. Filters and Slicers

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

  1. Store bar chart › Filters pane › Store › Filter type Top N.
  2. 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

  1. Select a bar chart with Product[Product Name] on the axis (City slicer = Nagpur).
  2. In Filters on this visual, expand Product Name › Filter type › Top N.
  3. Show items: Top, 5. Drag [Total Sales] into By value › Apply filter.
  4. 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.

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...

  1. Rank by Units (Hard): Shown per Reps Name. Measure: Units Rank = rank of [Total Units] among all Reps Name values.
  2. Top 3 only (Hard): Shown per Reps Name. Measure: Top 3 Units = [Total Units] when the rank is 3 or better, else blank.
  3. Units of the top 2 (Hard): Measure: Top 2 Units = [Total Units] for the 2 best Reps names.
  4. Total Units (Easy): Measure: Units Sum = SUM of Units.
  5. Share of Units (Medium): Shown per Reps Name. Measure: Units Share = SUM of Units ÷ SUM of Units for all of Reps.
  6. Return Rate (Medium): Shown per Reps Name. Measure: Return Rate = SUM of Returned ÷ SUM of Units.
  7. Only big reps (Medium): Shown per Reps Name. Measure: Big Units = [Total Units] when it is more than 8000, else blank.
  8. Rows per Rep (Easy): Shown per Reps Name. Measure: Row Count = number of RxSales rows.
  9. Units for Diabetes only (Medium): Shown per City. Measure: Units Diabetes = SUM of Units where Therapy is "Diabetes".
  10. Average Units per row (Medium): Shown per Reps Name. Measure: Units per Row = SUM of Units ÷ number of rows.

Ravi Sir's Cards for this lesson

मराठी cards