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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.