Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
Hello Power BI Community,
I am using a native table and a field parameter and I want the table to be sorted based on top N when selecting a field parameter. I have tried doing this on Filter pane but it doesn't work. any advice?
Please check the image and DAX below just to help you understand. I want the highlighted columns to be sorted highest to lowest/ Top N when a field parameter is selected.
Solved! Go to Solution.
Hi @jamal29 ,
Sorry for being late! If the Past 5 GW points, Past 3 GW points, Total Points per player are currently all measures, it can still be achieved after my test:
And the measure is like this:
Measure 2 =
VAR _5 = RANK(DENSE, ALL('Table'), ORDERBY('Table'[_Past 5], DESC))
VAR _3 = RANK(DENSE, ALL('Table'), ORDERBY('Table'[_Past 3], DESC))
VAR _total = RANK(DENSE, ALL('Table'), ORDERBY('Table'[_Total], DESC))
RETURN
IF(
MAX('Parameter 2'[Parameter]) = "_Past 5",
IF(
_5 <= 5,
1,
0
),
IF(
MAX('Parameter 2'[Parameter]) = "_Past 3",
IF(
_3 <= 3,
1,
0
),
IF(
MAX('Parameter 2'[Parameter]) = "_Total",
IF(
_total <= 10,
1,
0
),
1
)
)
)
The final output is as below:
Note: It is on the Page2 in the pbix.
Best Regards,
Dino Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @jamal29 ,
If I understand you correctly, you want to implement both the filtering of the field and the filtering of the first N of that column when selecting the parameter. You can try the following method:
Here's the rule I set up: if you choose Total Points per player, you return the entire contents of the column; if you choose Past 5 GW Points, you return the first 5 records in the column from largest to smallest; if you choose Past 3 GW Points, you return the first 3 records in the column from largest to smallest; if you choose Past GW Points, you return the first 10 records in the column from largest to smallest.
I use this DAX to create a new measure:
Measure =
VAR _5 = RANK(DENSE, ALL('Table'), ORDERBY('Table'[Past 5 GW Points], DESC))
VAR _3 = RANK(DENSE, ALL('Table'), ORDERBY('Table'[Past 3 GW Points], DESC))
VAR _total = RANK(DENSE, ALL('Table'), ORDERBY('Table'[Total Points per player], DESC))
RETURN
IF(
MAX('Parameter'[Parameter]) = "Past 5 GW Points",
IF(
_5 <= 5,
1,
0
),
IF(
MAX('Parameter'[Parameter]) = "Past 3 GW Points",
IF(
_3 <= 3,
1,
0
),
IF(
MAX('Parameter'[Parameter]) = "Past GW Points",
IF(
_total <= 10,
1,
0
),
1
)
)
)
Follow the screenshot below to set it up:
The final output is as below:
If you need to realize the data in the table is also arranged from large to small, this can not be achieved using DAX, only you can manually click here to achieve:
Best Regards,
Dino Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
Hi Dino,
Really appreciate for your comment here. I can see your measure has variables related to a specific table such as,
Hi @jamal29 ,
Sorry for being late! If the Past 5 GW points, Past 3 GW points, Total Points per player are currently all measures, it can still be achieved after my test:
And the measure is like this:
Measure 2 =
VAR _5 = RANK(DENSE, ALL('Table'), ORDERBY('Table'[_Past 5], DESC))
VAR _3 = RANK(DENSE, ALL('Table'), ORDERBY('Table'[_Past 3], DESC))
VAR _total = RANK(DENSE, ALL('Table'), ORDERBY('Table'[_Total], DESC))
RETURN
IF(
MAX('Parameter 2'[Parameter]) = "_Past 5",
IF(
_5 <= 5,
1,
0
),
IF(
MAX('Parameter 2'[Parameter]) = "_Past 3",
IF(
_3 <= 3,
1,
0
),
IF(
MAX('Parameter 2'[Parameter]) = "_Total",
IF(
_total <= 10,
1,
0
),
1
)
)
)
The final output is as below:
Note: It is on the Page2 in the pbix.
Best Regards,
Dino Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
84 | |
76 | |
73 | |
42 | |
36 |
User | Count |
---|---|
109 | |
56 | |
52 | |
48 | |
43 |