Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
D_PBI
Post Patron
Post Patron

Top N filter at page level - is it possible?

Hi all,
I've used a Top N filter at a visual level just fine, but I want to place a Top N filter at the Page level. I cannot see this option when configuring it. Is it possible?
Thanks.

5 REPLIES 5
D_PBI
Post Patron
Post Patron

Thanks for your replies.
I already have a measure that calculates the Top N that I apply as a visual level filter, although I need to apply this to each visual where I want the Top N filtering applied. If I could apply the filter to the page level, it would negate the need to apply it to several visuals.
The report I'm looking to add this to is unfamilar to me, so I'm not looking to rework the model to optimise the use of the Top N filter need.
Thanks again.

The TopN filter isn't available as a page-level filter because it's designed to work directly on a specific column within an individual visual. Applying this ranking to the entire page would require resolving the measure consistently across all visuals, which I don't think is supported by the filter framework.










Did I answer your question? Mark my post as a solution!


Proud to be a Super User!









"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.
danextian
Super User
Super User

Hi @D_PBI 

The TopN filter must be applied to a column within a visual. Even if you don't use the TopN feature, you'll still need to create a measure to act as a visual filter for each individual visual. However, with this approach, you can parameterize the filter, allowing a slicer selection to influence multiple visuals simultaneously.

 

danextian_0-1736420907346.png

Please see the attached sample pbix










Did I answer your question? Mark my post as a solution!


Proud to be a Super User!









"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.
rajendraongole1
Super User
Super User

Hi @D_PBI  - In Power BI, Top N filters are typically applied at the visual level, and no direct "Top N" filter option at the page level in the filter pane.

 

you can create a measure flag and perform top N filter and apply it. below example:

IsTopN =
IF(
RANKX(ALL(financials[product]), SUM(financials[product]), , DESC) <= 5, -- Replace 5 with your N
1,
0
)

 

I hope this helps. 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





DataNinja777
Super User
Super User

Hi @D_PBI ,

 

Power BI does not natively offer the ability to apply a Top N filter directly at the page level in the same way it does at the visual level. However, there are effective ways to achieve a similar result by using DAX measures or calculated tables, combined with slicers to dynamically control the Top N filtering across an entire page.

One way to achieve this is by creating a dynamic Top N slicer that can be applied across all visuals on the page. First, you need to create a parameter table to act as the slicer. You can do this by adding a new table in the Power BI model using the following DAX expression: TopN_Parameter = GENERATESERIES(1, 10, 1). This table will provide a list of numbers from 1 to 10, representing the Top N values that users can select through a slicer.

Once the parameter table is created, you need to define a measure that will dynamically calculate the Top N based on the slicer selection. The measure can be written as follows:

Top N Sales =
VAR TopNValue = SELECTEDVALUE(TopN_Parameter[Value], 5)
RETURN
CALCULATE(
    [Total Sales],
    FILTER(
        ALL('YourTable'),
        RANKX(ALL('YourTable'), [Total Sales]) <= TopNValue
    )
)

This measure calculates the rank of each entry in your dataset and filters the data to show only those entries that fall within the selected Top N range. The measure can then be used in your visuals to ensure they dynamically adjust based on the slicer selection.

Another approach is to create a calculated table that filters the dataset to only include the Top N records based on a selected measure. You can create this table by entering the following DAX expression in a new calculated table:

TopN_Table =
VAR TopNValue = SELECTEDVALUE(TopN_Parameter[Value], 5)
RETURN
TOPN(TopNValue, 'YourTable', [Total Sales], DESC)

This calculated table will only contain the top entries based on the selected value from the slicer. Using this table as the data source for your visuals ensures that only the desired Top N entries are displayed across the entire report page.

If you want to use a simpler approach that does not rely on slicers, you can create a calculated column using the RANKX function to rank the entries in your table. This column can then be used as a page-level filter. For instance, you could create a calculated column with the following DAX expression:

Rank = RANKX(ALL('YourTable'), [Total Sales], , DESC)

Once the column is created, you can go to the “Filters on this page” section in Power BI and apply a filter to show only rows where the Rank value is less than or equal to your desired Top N value. This will limit the data displayed across all visuals on the page to the top-ranked entries.

The best method depends on your specific use case. If you need a dynamic solution that allows users to control the Top N filtering through a slicer, the first method using a dynamic measure is highly recommended. If you want a more static filter that applies across the entire page without user interaction, using a calculated column with RANKX and a page-level filter is simpler to implement. Alternatively, if you need to limit the entire data model to only the Top N records, using a calculated table is an effective approach, though it may be performance-heavy for large datasets.

 

Best regards,

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.