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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
Vish24
Helper II
Helper II

Ranking is not showing correctly on card

Hello All,

 

I have seen so many posts and tried their solutions but nothing is working out. Please help me with this ranking:

I have my Data for sles with names and year:

Names  Year  Sales

A          2019    222

A          2019    456  

A          2018   678 

B          2019   555 

B         2018  33 

C        2018    23

 

I have two slicers for Name and Year: I want to show th rank of selected name with selected year. If year is not selected then combine ranking of 2018+2019 sales. My ranking is coming fine in table but its coming wrong in card.

 

Please Help!

 

 

 

C

1 ACCEPTED SOLUTION
mwegener
Most Valuable Professional
Most Valuable Professional

Hi @Vish24 

 

try this...

rank = RANKX(ALL('Table'[Name]),CALCULATE(SUM('Table'[Sales])),,DESC,Dense)

... and put an advanced filter on the (card) visual "Table [Year] is not blank"

 

Regards,

Marcus

Dortmund - Germany
If I answered your question, please mark my post as solution, this will also help others.
Please give Kudos for support. 

Did I answer your question?
Please mark my post as solution, this will also help others.
Please give Kudos for support.

Marcus Wegener works as Full Stack Power BI Engineer at BI or DIE.
His mission is clear: "Get the most out of data, with Power BI."
twitter - LinkedIn - YouTube - website - podcast - Power BI Tutorials


View solution in original post

19 REPLIES 19
v-gizhi-msft
Community Support
Community Support

Hi,

 

Please try to add an index column in Query Editor.

And then create a measure to show the rank:

rank = RANKX(ALL('Table'),CALCULATE(SUM('Table'[Sales])),,DESC,Dense)

Add this measure into table visual, when you do not choose any slicer, it shows:

32.PNG

When you choose year and name, it shows:

31.PNG

Hope this helps.

 

Best Regards,

Giotto Zhi

 

@v-gizhi-msft  Thank you! I will check this and confirm if its my solution.

@v-gizhi-msft hello, did you try this ranking measure on card display. its not showing correct ranking in card if I am selecting a name from slicer. In table its coming fine.

 

mwegener
Most Valuable Professional
Most Valuable Professional

Hi @Vish24 ,

 

@v-gizhi-msft  solution looks correct.

PBIX

But what do you mean with this?

If name is not selected the show the rank of 2018+2019.

 

Regards,

Marcus

Dortmund - Germany
If I answered your question, please mark my post as solution, this will also help others.
Please give Kudos for support.

Did I answer your question?
Please mark my post as solution, this will also help others.
Please give Kudos for support.

Marcus Wegener works as Full Stack Power BI Engineer at BI or DIE.
His mission is clear: "Get the most out of data, with Power BI."
twitter - LinkedIn - YouTube - website - podcast - Power BI Tutorials


@mwegener sorry that was a mistake. I meant if year slicer is not selected then it should show rank of 2018+2019 sales.

Hi,

 

The measure in a Card visual can only show the single value.

According to your description that if name is not selected, then it should show the rank of 2018+2019.

But for each year, it has different ranks and can not be put in a Card visual as one single value.

Do you want to compare 2018+2019 total sales with other year's total sales such as 2017 or 2016?

Please give more info.

 

Best Regards,

Giotto Zhi

 

@v-gizhi-msft sorry, that was a typing error. I meant if year is not selected and only name is selected then it will show ranking based on 2018+2019 sales.

mwegener
Most Valuable Professional
Most Valuable Professional

Hi @Vish24 ,


is your problem solved?
If I answered your question, please mark my post as solution, this will also help others.
Please give Kudos for support.

Did I answer your question?
Please mark my post as solution, this will also help others.
Please give Kudos for support.

Marcus Wegener works as Full Stack Power BI Engineer at BI or DIE.
His mission is clear: "Get the most out of data, with Power BI."
twitter - LinkedIn - YouTube - website - podcast - Power BI Tutorials


Hi,

 

Please try this rank measure:

rank = IF(SELECTEDVALUE('Table'[Year])<>BLANK(),RANKX(ALLSELECTED('Table'),CALCULATE(SUM('Table'[Sales])),,DESC,Dense),RANKX(ALL('Table'),CALCULATE(SUM('Table'[Sales])),,DESC,Dense))

 

Best Regards,

Giotto Zhi

 

mwegener
Most Valuable Professional
Most Valuable Professional

Hi @Vish24 

 

try this...

rank = RANKX(ALL('Table'[Name]),CALCULATE(SUM('Table'[Sales])),,DESC,Dense)

... and put an advanced filter on the (card) visual "Table [Year] is not blank"

 

Regards,

Marcus

Dortmund - Germany
If I answered your question, please mark my post as solution, this will also help others.
Please give Kudos for support. 

Did I answer your question?
Please mark my post as solution, this will also help others.
Please give Kudos for support.

Marcus Wegener works as Full Stack Power BI Engineer at BI or DIE.
His mission is clear: "Get the most out of data, with Power BI."
twitter - LinkedIn - YouTube - website - podcast - Power BI Tutorials


@v-gizhi-msft thank you for your response. But I want the final result for C with year 2019 to be rank 5 and sum of sales 37. its not ranking as per the total sales for each year

Hi,

 

Please try to change the original rank measure to this:

rank = RANKX(ALLEXCEPT('Table','Table'[Year]),CALCULATE(SUM('Table'[Sales])),,DESC,Dense)

And it shows:

71.PNG

 

Best Regards,

Giotto Zhi

amitchandak
Super User
Super User

Refer to this: Here I have tried to show 1st, 2nd rank by brand. In case the year is filter this should work

https://community.powerbi.com/t5/Community-Blog/Winner-Topper-on-Map-How-to-Color-States-on-a-Map-wi...

 

Also refer :

https://community.powerbi.com/t5/Desktop/Rankx-by-Group-with-filter/m-p/922597#M442150

 

Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution. In case it does not help, please provide additional information and mark me with @
Thanks. My Recent Blog -
Winner-Topper-on-Map-How-to-Color-States-on-a-Map-with-Winners , HR-Analytics-Active-Employee-Hire-and-Termination-trend
Power-BI-Working-with-Non-Standard-Time-Periods And Comparing-Data-Across-Date-Ranges

Connect on Linkedin

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

@amitchandak  Thanks! I will go through this and let you know if I am able to do this.

@amitchandak I couldn't see the attached button to attach my sample file. But here is my data. I am not sure if the blanks for year are giving any problem:

 

NameSalesYear
A1232018
A232019
A455 
B342018
B3452019
C222018
C242019
C132019
C12 
D452018
D5652019
A3442018
A44442019
C222018
B1342018
B5674 
A3646542018
E24322018
E6572019
F576 
F23432018

I have slicer for name and year. I need to show rank of selected year and name in a card. If name is not selected the show the rank of 2018+2019. As on my page I have filter to take only non blank year values: 

 

@mwegener if you could help with this whenever you get time. I have tried many solutions but nothing is woring with card display. Rank is coming fine in table display but when I am selecting a name from slicer its not giving corrrect rank on card disply.

 

 

Re: Ranking is not showing correctly on card

I couldn't see the attached button to attach my sample file. But here is my data. I am not sure if the blanks for year are giving any problem:

 

NameSalesYear
A1232018
A232019
A455 
B342018
B3452019
C222018
C242019
C132019
C12 
D452018
D5652019
A3442018
A44442019
C222018
B1342018
B5674 
A3646542018
E24322018
E6572019
F576 
F23432018

I have slicer for name and year. I need to show rank of selected year and name in a card. If name is not selected the show the rank of 2018+2019. I don't need to include the sales in calculation for which year is blank.

 

Thank you!

tkirilov
Resolver I
Resolver I

Hi @Vish24 ,

 

Perhaps that's because a card would only display first/last rank or count and a workaround to that would be to have a name selected by default in the name slicer, which users can then change to see the relevant rank for other names. I hope that helps. 

 

Best wishes,

 

T

Thank you for your response. I tried but still its not showing correctlt for some.

That potentially means that there are some rankings missing or not calculated correctly, so I'd encourage you to review your rank calculation method. Perhaps you could share an image of that?

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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.

Top Solution Authors