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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Anonymous
Not applicable

RANKX - rank with only one column in Table visual

Hi, I'm struggling with making rank with only one column if there are multiple columns in the Table visual. 

So basically I want to make rank with Key1 only when there is Key2 in the Table.

 

I tried a lot of rank measures. Basic rank meausre is RANKX(ALL('Table'[Key1]),CALCULATE(SUM('Table'[Value]))).I tried rankx with HASONEVALUE, ALLEXCEPT, ALLSELECTED, ALLEXCEPT but none of them helped me.

 

As you can see in the pictures below, if there is only Key1, rank works fine. But when Key2 is added, it gives a rank within the group of Key1 and Key2. 

P210R_0-1686849354961.png

P210R_1-1686849375638.png

 

Can anyone helps me? Any helps are welcomed. Thanks!

p.s. I tried to upload my PowerBI file but it's not supported. This is the table I used.

Table = DATATABLE(
    "Value", INTEGER,
    "Key1", STRING,
    "Key2", STRING,
    "Key3", STRING,
    {
        {100, "A", "a", "1a"},
        {300, "B", "b", "1b"},
        {150, "C", "a", "1c"},
        {120, "D", "b", "1d"}
    }
)
1 ACCEPTED SOLUTION
Ritaf1983
Super User
Super User

Hi @Anonymous 
Try this measure :

Rank Key1 = RANKX(
    ALL('Table 2'[Key 1]),
    CALCULATE(SUM('Table 2'[value]), ALLEXCEPT('Table 2', 'Table 2'[Key 1]))
)
Ritaf1983_0-1686888149323.png

Link to a sample file 

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

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

View solution in original post

1 REPLY 1
Ritaf1983
Super User
Super User

Hi @Anonymous 
Try this measure :

Rank Key1 = RANKX(
    ALL('Table 2'[Key 1]),
    CALCULATE(SUM('Table 2'[value]), ALLEXCEPT('Table 2', 'Table 2'[Key 1]))
)
Ritaf1983_0-1686888149323.png

Link to a sample file 

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

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors