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
GWoodhouse
New Member

Problems with DAX RankX

I have a table containing Country names and Priority Orders

Country Priority

UK          1

US          1

NL          2

 

and another table containing a measure that sums a value

What I want is

Rank    Priority  Country   SumofValue

1          1            US           1000

2          2            NL            900

3          1            UK            800

 

But what I am getting is the following because it's ranking by country within the Priority groups

Rank    Priority  Country   SumofValue

1          1            US           1000

1          2            NL            900

2          1            UK            800

 

My DAX is al follows

Country Rank =
Rankx(
        all(Country[CountryName]),
        MySumMeasure,
        ,desc
        ,Dense
    )
 
Where am I going wrong?
Thanks in advance
1 ACCEPTED SOLUTION
FreemanZ
Super User
Super User

hi @GWoodhouse 

try like:

Country Rank =
Rankx(
        all(Country[CountryName]),
        CALCULATE[MySumMeasure], ALL(Country[Priority]),
        ,desc
        ,Dense
    )

View solution in original post

3 REPLIES 3
FreemanZ
Super User
Super User

hi @GWoodhouse 

try like:

Country Rank =
Rankx(
        all(Country[CountryName]),
        CALCULATE[MySumMeasure], ALL(Country[Priority]),
        ,desc
        ,Dense
    )

PERFECT!

Now please explain why that works 😉

[MySumMeasure], as a measure, has an implicit CALCULATE, which converts the row context - Priority, to filter context. 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

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

November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

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.