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
Anonymous
Not applicable

Rankx based on multiple columns

Hi All,

 

So I have this problem using rankx. I am using Excel, btw.

 

I have to rank my sales ignoring filter atrributes (Segment, Country, Product, Discount Band).

    This was my measure expression: 

  • Financial Sales:=CALCULATE(SUM(financials[Sales]))
  • Sales Rank:=RANKX(ALL(financials[Segment], financials[Country], financials[Product], financials[Discount Band]), [Financial Sales],, DESC, Dense)

After ranking my sales, I wanted to show the top 10 sales for the whole table using the following expressions:

  • Top10 Sales:=if([Sales Rank]<=10, [Financial Sales], BLANK())
  • Top10 Sales Rank:=if([Sales Rank]<=10, [Sales Rank], BLANK())

 

So basically, the outcome was what I wanted (see figure A). However, some weird entries appeared when I enabled the grand totals for column (see figure B).

 

Figure A.

1.JPG

 

Figure B.

2.jpg

 

How do i fix this?

Here's the file should you need to look at it. It's just a financial sample data from microsoft.

 

Thanks in advance!

 

1 ACCEPTED SOLUTION
v-rzhou-msft
Community Support
Community Support

Hi @Anonymous 

I download your excel and update your measure in Power BI Desktop.

Financial Sales = 
SUMX (
    FILTER (
        ALL ( financials ),
        financials[Segment] = MAX ( financials[Segment] )
            && financials[Country] = MAX ( financials[Country] )
            && financials[Product] = MAX ( financials[Product] )
            && financials[Discount Band] = MAX ( financials[Discount Band] )
    ),
    financials[ Sales]
)
Rank = 
IF(ISINSCOPE(financials[Discount Band]),RANKX(ALL(financials),[Financial Sales],,DESC,Dense),BLANK())

Build a Matrix visual to show the result.

1.png

You can download the pbix file from this link: Rankx based on multiple columns

 

Best Regards,

Rico Zhou

 

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

2 REPLIES 2
v-rzhou-msft
Community Support
Community Support

Hi @Anonymous 

Could you tell me if your problem has been solved? If it is, kindly Accept it as the solution. More people will benefit from it. Or you are still confused about it, please provide me with more details about your problem.

 

Best Regards,

Rico Zhou

v-rzhou-msft
Community Support
Community Support

Hi @Anonymous 

I download your excel and update your measure in Power BI Desktop.

Financial Sales = 
SUMX (
    FILTER (
        ALL ( financials ),
        financials[Segment] = MAX ( financials[Segment] )
            && financials[Country] = MAX ( financials[Country] )
            && financials[Product] = MAX ( financials[Product] )
            && financials[Discount Band] = MAX ( financials[Discount Band] )
    ),
    financials[ Sales]
)
Rank = 
IF(ISINSCOPE(financials[Discount Band]),RANKX(ALL(financials),[Financial Sales],,DESC,Dense),BLANK())

Build a Matrix visual to show the result.

1.png

You can download the pbix file from this link: Rankx based on multiple columns

 

Best Regards,

Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. 

 

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.