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
charlottesmn
Frequent Visitor

Dynamic Top N based on column ordering

Hello!
I have a table with customers and a couple of different metrics (number of orders, number of items bought, number of connections, total spent...). By default, the table is ordered by the number of orders. I would like to limit the table to show only the top 50 customers. However, I want the top 50 to update if the user decides to order the table by a different column. I know I can use the TOP N feature but I was not able to make this feature update based on the column chosen for the table ordering?

Thank you!

1 ACCEPTED SOLUTION

To make the TOP N filter dynamic based on the column selected by the user, you can create a dynamic slicer using a What-If Parameter:

 

1. Create a slicer table that contains all the headers of the columns you want to filter into one column.
2. Create a measure that uses the RANKX function to rank the values based on the selected column.
3. Use the slicer to filter the values based on the selected column.


The TOP N filter will update dynamically based on the column chosen for ordering by the user.

View solution in original post

5 REPLIES 5
v-shex-msft
Community Support
Community Support

Hi @charlottesmn ,

Did the above suggestions help with your scenario? if that is the case, you can consider Kudo or Accept the helpful suggestions to help others who faced similar requirements.

If these also don't help, please share more detailed information and description to help us clarify your scenario to test.

How to Get Your Question Answered Quickly 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
Sergii24
Super User
Super User

Hi @charlottesmn, take a look at this video which shows how exactly you can achieve the desired result! Even if it's not fully dynamic as you still need to hardcode selection values in DAX, it can be very useful in your further research.

Good luck!

AlphaBravo
New Member

To use the TOP N feature in Power BI, build your visual as usual. Then, click on the visual and open the filters pane. Add or select the filter you want to apply the TOP N filter to, in this case, the ‘Customers’ filter. Select TOP N, choose whether to show top or bottom items, and enter the number of items to show, which in this case is 50.

 

The crucial part is the ‘By value’ section. This is what determines what the top or bottom 50 are based on. Drop the related column in this section and click apply. Power BI will automatically pick a calculation for you, such as sum or count, but you can change this.

 

For example, you can choose it to be a SUM of Value delivered or a COUNT of instances delivered, depending on your data.

 

Note that the TOP N filter won't update dynamically if the user decides to order the table by a different column. It will always be based on the column you selected when setting up the filter. 

Thank you for the quick response. Is there any way to make the TOP N update based on the column the user selects? 

To make the TOP N filter dynamic based on the column selected by the user, you can create a dynamic slicer using a What-If Parameter:

 

1. Create a slicer table that contains all the headers of the columns you want to filter into one column.
2. Create a measure that uses the RANKX function to rank the values based on the selected column.
3. Use the slicer to filter the values based on the selected column.


The TOP N filter will update dynamically based on the column chosen for ordering by the user.

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!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

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.