Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

Reply
Krispi
New Member

RANKX across all levels and avoiding blank values

I'm looking for a way to rank all values independend if that are on the first level or second level of my hierarchy.

 

This is the hierarchy:

AreaCountry
AuNZAustralia
AuNZNew Zealand 
CanadaCanada
EuropeBelgium
EuropeGermany
EuropeFrance
UKUK

 

Some levels in my hierarchy have blank values:

 ValueRank
AuNZ65.1%2
  Australia<blank> 
  New Zealand<blank> 
Canada70.1%1
  Canada<blank> 
Europe<blank> 
  Belgium60.8%3
  Germany25.7%5
  France10.0%6
UK30.0%4
  UK<blank> 

 

As you can see, values are blank for all countries, except for the countries in Europe. Also for Europe itself the value is blank. 

I created this measure to get the right values at the right place:

 

Value =
    SWITCH(
        TRUE(),
        (SELECTEDVALUE(DimSummary[Area]) IN {"Europe"} && ISINSCOPE(DimSummary[Country]))
        ||
        (NOT(SELECTEDVALUE(DimSummary[Area]) IN {"Europe"}) && ISINSCOPE(DimSummary[Area]) && NOT(ISINSCOPE(DimSummary[Country]))),
        CALCULATE(DimLargeTable[Value],
            TREATAS(VALUES(DimSummary[Area]), DimLargeTable[Area]),
            TREATAS(VALUES(DimSummary[County]), DimLargeTable[Country])
    ))
 
Is this possible? I looked around I didn't see anybody doing RANKX across the complete hierarchy.
2 REPLIES 2
Krispi
New Member

Hi @Anonymous 

 

Thanks for sharing these examples! Problem is that all these rank at each level of the hierarchy and not across the levels of the hierarchy (or perhaps I missed that). 

 

I'll prepare an example PIBX. I cannot share the current version.

 

 

Thanks

Kris

Anonymous
Not applicable

Hi @Krispi ,

 

You can refer to the following posts that may be helpful to you:

Rankx in Matrix Hierarchy - Microsoft Fabric Community

 Rankx Multiple levels to Hierarchy - Microsoft Fabric Community

Power BI Ranking In Hierarchical Form (enterprisedna.co)

 

If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. Thank you.

 

Best Regards,

Neeko Tang

If this post  helps, then please consider Accept it as the solution  to help the other members find it more quickly. 

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.