Forum Discussion
Dynamic Top N based on column ordering
- 2 years ago
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.
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.
- charlottesmn2 years agoFrequent Visitor
Thank you for the quick response. Is there any way to make the TOP N update based on the column the user selects?
- AlphaBravo2 years agoNew Member
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.