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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

RANKX Question Help Needed

So I have a data set of locations with their corresponding values and I want to be able to rank them across the whole company and then also across their geographic regions and also their size categories. 

 

I have three tables "Values" connected to "Org Mapping" connected to "Org Sizing".

 

I have the following measures:

 

 

 

Value Measure = SUM('values'[Value])
Value Rank Across company = 
CALCULATE (
    IF (
        HASONEVALUE ( 'values'[Value] ),
        IF (
            NOT ( ISBLANK ( 'values'[Value Measure] ) ),
            RANKX (
                FILTER (
                    ALL ( 'Org Mapping'[Org ] ),
                    NOT ( ISBLANK ( 'values'[Value Measure] ) )
                ),
                'values'[Value Measure],
                ,
                ,
                DENSE
            )
        ),
        BLANK ()
    ),
    ALL ( 'Org Mapping'[Geo]),
    ALL ( 'Org Sizing'[Size Cat 1], 'Org Sizing'[Size Cat 2] )
)
Value Rank Across Selection = 
IF (
    HASONEVALUE ( 'values'[Value] ),
    RANKX (
        FILTER ( ALL ( 'Org Mapping'[Org ] ), 'values'[Value Measure] ),
        'values'[Value Measure],
        ,
        ,
        DENSE
    ),
    BLANK ()
)

 

 

 

The users should be able to select on Size category 1, Size category 2, and Geo to see where the locations rank within those groups but also be able to see where those locations rank across the whole company. I have also added a location selector so the user can go directly to a specific location if they choose. 

 

I am having two issues:

 

1. When a selection is made directly to a location it displays the same value for across selection and across company. I understand why this is happening. The user needs to select something for Size cat 1, 2, and geo for that measure to work properly. Is there anything I can do to force that measure to automatically rank across the three selections? Each location has a unique combination of size categories and geo.

 

2. I noticed that once my value goes negative the rankings for the one measure seem to be off. I have no idea why this is happening. 

 

 5-7-2020 1-13-40 PM.png

 

 

 

 

 

 

 

 

 

 

 

 

 

 

The Github link below has the randomized data I have been using to work on this as well as the PBIX. Any help is appreciated. Thank you.

 

https://github.com/DerekAG92/RANKX-Help

2 REPLIES 2
v-lili6-msft
Community Support
Community Support

hi  @Anonymous 

1.  you could try to use ALLSELECTED instead of ALL in the formula

https://powerbi.istanbul/all-allselected-ve-rasyolar/

 

2. You could just use this simple formula

Value Rank Across Selection = IF (
    HASONEVALUE ( 'values'[Value] ),
    RANKX (
       ALLSELECTED(  'Org Mapping'[Org ] ),
        'values'[Value Measure],
        ,
        ,
        DENSE
    ),
    BLANK ()
)

 

Regards,

Lin

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

So I was able to fix the rankings not being the same by changing the Value Rank Across Selection measure to being this:

 

Value Rank Across Selection = 
IF (
    HASONEVALUE ( 'values'[Value] ),
    IF (
        NOT ( ISBLANK ( 'values'[Value Measure] ) ),
        RANKX (
            FILTER (
                ALL ( 'Org Mapping'[Org ] ),
                NOT ( ISBLANK ( 'values'[Value Measure] ) )
            ),
            'values'[Value Measure],
            ,
            ,
            DENSE
        )
    ),
    BLANK ()
)

 

I dont really understand what is happening but it seems to be working. I still am not sure how to accomplish my other question. 

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

Fabric Community Sticker Design Challenge Barcelona Carousel

Fabric Community Sticker Challenge - Barcelona 2026

If you love stickers, then you will definitely want to check out our community sticker challenge, Barcelona edition!

July Power BI Update Carousel

Power BI Monthly Update - July 2026

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

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.

Top Solution Authors