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
logan_logan
Helper I
Helper I

show rank in cards (without any row)

Hi I want to show rank in cards.

Like 

Category     SALES

A                  22

B                  29

C                  50               

D                  60

 

So when I select category C, then in the card I should see '2' as the rank on sales is the second.

I treid this DAX that works in table/matrix but not on Cards.

Rank_LM = RANKX(ALL('table'[Categoy]),sum(SALES),,DESC)
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @logan_logan ,

Please try to create a measure with below dax formula:

Measure2 =
VAR _rk =
    RANKX ( ALL ( 'Table' ), CALCULATE ( MAX ( 'Table'[SALES] ) ),, DESC, DENSE )
VAR _result =
    IF ( ISFILTERED ( 'Table'[Category] ), _rk, BLANK () )
RETURN
    _result

Animation27.gif

Please refer the attached .pbix file.

 

Best regards,
Community Support Team_Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

Hi @logan_logan ,

Please try to create a measure with below dax formula:

Measure2 =
VAR _rk =
    RANKX ( ALL ( 'Table' ), CALCULATE ( MAX ( 'Table'[SALES] ) ),, DESC, DENSE )
VAR _result =
    IF ( ISFILTERED ( 'Table'[Category] ), _rk, BLANK () )
RETURN
    _result

Animation27.gif

Please refer the attached .pbix file.

 

Best regards,
Community Support Team_Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

I had to tweak a lillte bit as I had two categories but **bleep** worked. Thanks.

DallasBaba
Skilled Sharer
Skilled Sharer

@logan_logan you can reshape with a CALCULATE function:

 

Rank_LM_Category2 =
RANKX(
FILTER('table', 'table'[Category] = "Category 2"),
CALCULATE(SUM('table'[Sales]), ALL('table'[Category])),
,
DESC
)

 

Let me know if this works

Thanks

Thanks
Dallas
logan_logan
Helper I
Helper I

Hi,

Actually I will filter another category(lets say caterogy 2) and then I need the rank on category (A,B,C,D). 

So can you please reshape your dax?

DallasBaba
Skilled Sharer
Skilled Sharer

@logan_logan let try FILTER constent to your meassure for the table to include only the rows where the Category matches the selected category in your card.

 

Rank_LM =
RANKX(
FILTER('table', 'table'[Category] = SELECTEDVALUE('table'[Category])),
SUM('table'[Sales]),
,
DESC
)

 

Let me know if this works

Thanks

Thanks
Dallas

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.