Forum Discussion
Dynamic Top N Ranking with Bucket-Based Filter Context
- 3 months ago
Hi Julia2023 ,
I was able to reproduce the scenario successfully using a sample dataset, and the ranking/filtering worked correctly with the shared approach.
I have attached a sample PBIX file for reference so you can compare the implementation with your current model/setup.
If the issue still exists, please share the following details -
sample data/model structure
expected output
current output screenshotso the exact filter context behavior can be reproduced and checked further.
Thank you.
Hi!!
The problem is your Rank Products measure uses ALL('Product'[Product]) which ignores all filters including the bucket selection. You need it to rank only within the current filter context.
Change it to use ALLSELECTED instead:
daxRank Products =
RANKX(ALLSELECTED('Product'[Product]), [Actual Sales $])
ALLSELECTED respects filters coming from slicers and cross-filtering from other visuals, so when someone clicks a bucket in the matrix it will rank only the products within that filtered set. The Top N flag then naturally applies to that ranked subset.