Top N Slicer

Dynamic Top N Filtering

Build

Featured Image

Overview

Features

Prompts

Troubleshooting

Key Features

Add a RANK-based Top N filter to any chart with a numeric slider slicer, dynamic title, and scoped interactions.

Your bar chart shows every product, country, or customer — but you only care about the top performers. Power BI's built-in Top N filter uses TOPN which breaks with external slicers and doesn't update dynamically. The SQLBI-recommended approach uses RANK with ALLSELECTED to respect all slicer context, but implementing it means building a disconnected table, a RANK measure with the right ALLSELECTED scope, a visual-level filter, a dynamic title measure, a numeric slicer, and interaction restrictions so the slicer only affects the target chart. This skill builds all of it in one command.

How it works

Type /top-n-rank, provide the visual ID, dimension, and ranking measure, and the skill builds everything:

  1. Creates a disconnected TopN table with GENERATESERIES (reuses existing one if present)

  2. Creates a Show/Hide measure using RANK(DENSE, ALLSELECTED) — returns 1 for top N items, 0 otherwise

  3. Creates a dynamic title measure — "Top N {Items} by {Measure}"

  4. Applies a hidden visual-level filter (Show/Hide = 1) on the target chart

  5. Sets the dynamic title on the chart

  6. Adds a "Top" text label and numeric slider slicer above the chart

  7. Restricts slicer interactions so the TopN slicer only filters the target chart

What you get

  • Disconnected TopN table — GENERATESERIES with configurable range and default N

  • 2 DAX measures{Prefix}Show/Hide (RANK filter) and {Prefix}Title Top (dynamic title)

  • Visual-level filter — hidden Advanced filter on Show/Hide = 1

  • Dynamic title — updates automatically when N changes (e.g., "Top 10 Countries by Sales")

  • Numeric slider slicer — compact slider with default selection, no header, transparent background

  • "Top" text label — positioned above the chart, aligned with the slicer

  • Scoped interactions — slicer only affects the target chart, not other visuals on the page

Why RANK over RANKX

Feature

RANK (used here)

RANKX

Totals behavior

Auto-returns BLANK

Needs ISINSCOPE guard

Floating-point precision

No issues

Can misrank due to rounding

Multi-column ordering

Native ORDERBY

Requires nested RANKX

SQLBI recommendation

Current best practice

Legacy approach

Why ALLSELECTED over ALL

ALLSELECTED respects all external slicer filters — date, country, segment, and the dimension column itself. ALL would override a slicer on the same dimension, breaking user expectations.

Tool Information

Price

20 USD

Category

Build

Version

Version 1.0.0.2.13