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
I have read all over, and havent found something useful.
I have a dataset with 5 levels of hierarchy, and I am trying to create a leaderboard dashboard at different levels using the same slicer: when slicing for region, i need it to rank all levels of the hierarchy, not just the lowest level (store).
When trying to rank the "district" level (1 up from store), Im able to get a rank which works when unfiltered, and i end up with 1,2,3,4,5,...etc.
but when filtered, it doesnt rerank, and instead cuts out the filtered rows so I end up with 4,8,15,...etc.
Is there a way to filter and recalculate rank?
Here is the measure I created:
Rank5 =
IF (
FIRSTNONBLANK ( Store_Data[District], Store_Data[District] ) <> BLANK (),
RANKX (
FILTER ( allselected ( Store_Data[District] ), Store_Data[District] <> BLANK () ),
calculate(sum(Store_Data[Total Volume]),allexcept(Store_Data,Store_Data[District])),,,SKIP
)
)
thanks!
Solved! Go to Solution.
HI @mangoose,
You can try to use below measure formula to get dynamic rank:
Rank District A =
IF (
FIRSTNONBLANK ( Store_Data[District], Store_Data[District] ) <> BLANK (),
RANKX (
FILTER ( ALLSELECTED ( Store_Data ), Store_Data[District] <> BLANK () ),
CALCULATE (
SUM ( Store_Data[Total Volume] ),
ALLEXCEPT ( Store_Data, Store_Data[District] )
),,,DENSE
)
)
Rank District B =
RANKX (
ALLSELECTED ( Store_Data ),
CALCULATE (
SUM ( Store_Data[Total Volume] ),
ALLEXCEPT ( Store_Data, Store_Data[District] )
),,,DENSE
)
Regards.
Xiaoxin Sheng
Hi @mangoose,
Can you please share some sample data to test and coding formula? It is hard to clearly your scenario with any sample data.
BTW, it is hard to achieve dynamic ranking on hierarchy level. In my opinion, maybe you can write multiple calculation formulas for each level, then use if statement to check current level and return correspond calculation result from matched calculation formula.
Regards,
Xiaoxin Sheng
Hi Xiaoxin, happy to provide a demo. Thanks for your reply. I built a .pbix file here: Sample PBIX
Here is as simple as I can explain:
My dataset is as follows:
I created a measure summing up Total Volume, called "TotVol":
TotVol = sum(Store_Data[Total Volume])
Then I made a simple dashboard with both a store and a district leaderboard using rank functions:
As you can see, rankings work when unfiltered for both Store and District - highest volume = #1, second highest #2 etc.
However, when I filter for the "North" region, here is what it looks like:
As you can see, the store ranking is now correct, Store 2591 is now #1 (instead of #5 when unfiltered), but District NB D6 is first on the list, but still displays #5 in both of my rank measures. I want District NB D6 to display "1", and District EA D1 to display "2" etc.
Here are the rank functions (store works well, but neither district rank measures work)
Rank Total Volume Store =
IF (
FIRSTNONBLANK ( Store_Data[Store], Store_Data[Store] ) <> BLANK (),
RANKX (
FILTER ( allselected ( Store_Data ), Store_Data[Store] <> BLANK () ),
CALCULATE ( sum(Store_Data[Total Volume]))
)
)Rank District A =
IF (
FIRSTNONBLANK ( Store_Data[District], Store_Data[District] ) <> BLANK (),
RANKX (
FILTER ( allselected ( Store_Data[District] ), Store_Data[District] <> BLANK () ),
calculate(sum(Store_Data[Total Volume]),allexcept(Store_Data,Store_Data[District]))
)
)Rank District B = rankx(ALLSELECTED(Store_Data[District]),calculate(sum(Store_Data[Total Volume]),allexcept(Store_Data,Store_Data[District])))
HI @mangoose,
You can try to use below measure formula to get dynamic rank:
Rank District A =
IF (
FIRSTNONBLANK ( Store_Data[District], Store_Data[District] ) <> BLANK (),
RANKX (
FILTER ( ALLSELECTED ( Store_Data ), Store_Data[District] <> BLANK () ),
CALCULATE (
SUM ( Store_Data[Total Volume] ),
ALLEXCEPT ( Store_Data, Store_Data[District] )
),,,DENSE
)
)
Rank District B =
RANKX (
ALLSELECTED ( Store_Data ),
CALCULATE (
SUM ( Store_Data[Total Volume] ),
ALLEXCEPT ( Store_Data, Store_Data[District] )
),,,DENSE
)
Regards.
Xiaoxin Sheng
Check out the November 2025 Power BI update to learn about new features.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
| User | Count |
|---|---|
| 58 | |
| 45 | |
| 42 | |
| 20 | |
| 18 |