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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
shaunwilks
Helper V
Helper V

RANKX Rank specific measure value in table

 

Hello All,

 

Any help would be greatly appreciated. 

Example table...

 Table1

Code             Date                          Sales$

AA                 12/10/2018               200.00

BB                 11/10/2018               200.00

AA                 10/10/2018               200.00

CC                 12/10/2018               200.00

DD                 14/10/2018              200.00

FF                 15/10/2018               200.00

FF                 17/10/2018               200.00

AA                 18/10/2018              200.00

 

I want to create a specifc ,measure to return me the rank of the string AA amongst the above sales.

I dont wish to have a table to collate totals for other reason.

The idea will be to have five seperate Measures that store the rank for AA BB CC DD FF.

These will be represented in cards on the report - I dont want to have to set Visual filters on each card.

 

is there a way in the RANKX statment where I can specify the text to rank.

 

ie What rank is Code "AA" in Table1.Code field for Sum(Sales$)

I have done rank statements before but they have always been for column names and been able to use for any code in the table.

In this example I wish to fix the Code and seek a rank for it.

 

Any suggestions welcome and help appreciated in advance.

1 ACCEPTED SOLUTION
Zubair_Muhammad
Community Champion
Community Champion

HI @shaunwilks

 

Try this MEASURE pattern

 

Measure =
CALCULATE (
    RANKX ( ALL ( TableName[Code] ), CALCULATE ( SUM ( TableName[Sales$] ) ) ),
    TableName[Code] = "AA"
)

Regards
Zubair

Please try my custom visuals

View solution in original post

2 REPLIES 2
Zubair_Muhammad
Community Champion
Community Champion

HI @shaunwilks

 

Try this MEASURE pattern

 

Measure =
CALCULATE (
    RANKX ( ALL ( TableName[Code] ), CALCULATE ( SUM ( TableName[Sales$] ) ) ),
    TableName[Code] = "AA"
)

Regards
Zubair

Please try my custom visuals

 

Thanks very much - my production report was somewhat more complicated but the suggested formula you provided was a big help.

I find myself comfortable with most DAX function but the RANKX one totally consfuses me.

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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