Forum Discussion
How to create a dynamic top N for a matrix with multiple values
- 1 year ago
Hi donnie17
Yes, you can achieve it.
As a first step create a parameters table for selecting Top nAnd the 2 measures according to yours, like in my case:
1.
TopN country profits =VAR SelectedTop = SELECTEDVALUE('Top n'[Top n])RETURNSWITCH(TRUE(),SelectedTop = 0, [total profits (K/$)],RANKX (ALLSELECTED( 'Customers'[Country] ),[Total sales (K/$)])<= SelectedTop,[total profits (K/$)])2.TopN country sales =VAR SelectedTop = SELECTEDVALUE('Top n'[Top n])RETURNSWITCH(TRUE(),SelectedTop = 0, [total_sales],RANKX (ALLSELECTED( 'Customers'[Country] ),[Total sales (K/$)])<= SelectedTop,[Total sales (K/$)])Result :The pbix is attached
If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly
- 1 year ago
Hi donnie17 You already done all the work. You just need to do a small thing. Select the matrix visual, go to filter pane, Select Total Sales and set to "Is not blank", Click apply. You are done.
I have tried to implement your scenario. See images:
No filter applied:
After applied filter:
Hope this helps!!
If this solved your problem, please accept it as a solution!!
Best Regards,
Shahariar Hafiz
donnie17Thank you for sharing your query. Could you please share the pbix file with some sample data ?