Forum Discussion

kompalli's avatar
kompalli
Icon for Helper I rankHelper I
3 years ago
Solved

Rank in a card

Hi
Need Help
I was trying to display rank in a card. Below are the details of I am trying to do.

  • Below is the Table I have Company names and sales. One company has different names so I ranked first based on all companies and then tried to filter Nike rankings to get the top rank among the Nike company. 

 

Below are the measures which I used.

NIKE Sales Ranking =
VAR A =  RANKX(
        ALL(Company[Company]),
        [Total sales])
VAR _Rank = IF(MAX(Company[Market/Nike]) = "NIKE",A)
RETURN
_Rank
 
 
 By using below formula I was able to get the top company name based on ranking among Nike Company as shown in the above screenshot. But I want to display the Rank of the top company in the card. Is there any work around where I can display Rank value on the card.
 
Top Nike Sales =
FIRSTNONBLANK (
    TOPN (
        1,
        VALUES ( Company[Company]),
        CALCULATE ([NIKE Sales Ranking]),ASC
    ),
    1
)
  • Anonymous's avatar
    Anonymous
    3 years ago

    Hi kompalli ,

    I updated my sample pbix file(see the attachment), please check if that is what you want. It return 3 not 4, I'm not sure if it is correct or not...

    NIKE Sales Ranking = RANKX ( ALL ( Company ), [Total sales] )
    Measure = 
    VAR _tab =
        SUMMARIZE (
            'Company',
            'Company'[Market/Nike],
            'Company'[Company],
            "@totalsales", [Total sales],
            "@rank", [NIKE Sales Ranking]
        )
    RETURN
        MINX ( FILTER ( _tab, Company[Market/Nike] = "NIKE" ), [@rank] )

    Best Regards

6 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi kompalli ,

    What's your expected result? Do you want to get the rank value or the sales which the rank is 1? Since you only need to get the top 1 customer, then the rank value should be 1. If you want to get the sales which the rank is 1, you can create a measure as below to get it:

    Measure = 
    VAR _tab =
        SUMMARIZE (
            'Company',
            'Company'[Market/Nike],
            'Company'[Company],
            "@totalsales", [Total sales],
            "@rank", [NIKE Sales Ranking]
        )
    RETURN
        MAXX ( FILTER (_tab, [@rank] = 1 ), [@totalsales] )

    If the above one can't help you get the expected result, could you please provide more raw data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples? It would be helpful to find out the solution. You can refer the following links to share the required info:

    How to provide sample data in the Power BI Forum

    How to Get Your Question Answered Quickly

    And It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

    How to upload PBI in Community

    Best Regards

    • kompalli's avatar
      kompalli
      Icon for Helper I rankHelper I

      Hi Anonymous 

       

      Thanks for you quick response, The method you followed is exactly what I need but I want to show top Rank of Nike in the card and not the sales value or company name. Can that be done.

       

      Thanks in advance

      • Anonymous's avatar
        Anonymous
        Not applicable

        Hi kompalli ,

        I'm not clear about your requirement, could you please provide the exact value which you want to display in the card visual finally base on the below table data?

        Best Regards