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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

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
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors