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
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

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


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.

 

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


@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.

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


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

 

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


@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

@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
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.

Top Solution Authors