Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Hii
i have a requirement to display dynamic Top N category based on country and i am using Matrix visual
i am using this DAX function
Solved! Go to Solution.
Hi @sarjensystems1 ,
I have changed your measure and I guess this time it will satisfy your need:
TopN Sales =
VAR SelectedTop = SELECTEDVALUE('TopN'[TopN])
RETURN
SWITCH(TRUE(),
SelectedTop = 0, [sales],
RANKX (
ALL('Table'),
[sales]
)
<= SelectedTop,
[sales]
)
And you will see:
For the related .pbix file,pls click here.
Best Regards,
Kelly
Hi @sarjensystems1 ,
I have changed your measure and I guess this time it will satisfy your need:
TopN Sales =
VAR SelectedTop = SELECTEDVALUE('TopN'[TopN])
RETURN
SWITCH(TRUE(),
SelectedTop = 0, [sales],
RANKX (
ALL('Table'),
[sales]
)
<= SelectedTop,
[sales]
)
And you will see:
For the related .pbix file,pls click here.
Best Regards,
Kelly
Hi @sarjensystems1 ,
I'm not sure whether [sales] is a column or measure,but I tried to use your sample data and create a measure names [sales],when I select subcategory,it appears right, as you can see below:
For the related .pbix file,pls click here.
Best Regards,
Kelly
Hi,
Share some data and show the expected result.
I did not test it but
You might have to try ALLEXCEPT( Query1[Category]) in place of ALL( Query1[Category]).
Refer
https://radacad.com/how-to-use-rankx-in-dax-part-2-of-3-calculated-measures
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 38 | |
| 38 | |
| 36 | |
| 28 | |
| 28 |
| User | Count |
|---|---|
| 124 | |
| 88 | |
| 74 | |
| 66 | |
| 65 |