cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
tanlamquach Frequent Visitor
Frequent Visitor

Ranking Not Working Properly

Hi guys

Need help before I pull all my hair out

The ranking works fine for everything except for the red circled, it should be 1 instead of 2
Capture.PNG

Sales Rank =
IF (
ISINSCOPE ( 'Product'[Product Category] ),
RANKX ( ALL ( 'Product'[Product Category] ), [Sales Amount],, DESC ),
IF (
ISINSCOPE ( 'Product'[Product Line] ),
RANKX ( ALL ( 'Product'[Product Line] ), [Sales Amount],, DESC ),
BLANK ()
)
)

 

Here is the link of the pbix file on google drive

https://drive.google.com/open?id=1lBfXbT8ZFWSEcbKizBypfrGrJez4Ptp7

 

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
Super User IV
Super User IV

Re: Ranking Not Working Properly

That is very odd behavior, I can only think that it has something to do with [Product Category] "Fuses" have a sales amount larger than the #2 ranked [Product Line].  

However, switching it to to using HASONEVALUE seems to fix it.

Ranking = 
IF ( HASONEVALUE ( 'Product'[Product Category] ),
    RANKX ( ALL ( 'Product'[Product Category] ), [Sales Amount] ),
    IF ( HASONEVALUE ( 'Product'[Product Line] ),
        RANKX ( All ( 'Product'[Product Line] ), [Sales Amount] )
    )
)

Ranking.jpg

View solution in original post

2 REPLIES 2
Highlighted
Super User III
Super User III

Re: Ranking Not Working Properly

Hi @tanlamquach 

That looks strange, yes. I don't see anything wrong with your code. In fact, to make it stranger, I was running some tests and realized by chance that by adding another measure to the matrix visual, your measure all of a sudden yields the correct result. If I take my mock measure [Sales rank V3] off the visual, your measure yields the wrong results again. Try it on "Page 2" that I've added to your original file (see attachment). Add and remove [Sales Rank V3] to the visual and see how the result for "Circuit protection" changes between 1 and 2

 

Maybe knowledgeable people like @Zubair_Muhammad, @MFelix@Greg_Deckler can have a look and help here

   

Super User IV
Super User IV

Re: Ranking Not Working Properly

That is very odd behavior, I can only think that it has something to do with [Product Category] "Fuses" have a sales amount larger than the #2 ranked [Product Line].  

However, switching it to to using HASONEVALUE seems to fix it.

Ranking = 
IF ( HASONEVALUE ( 'Product'[Product Category] ),
    RANKX ( ALL ( 'Product'[Product Category] ), [Sales Amount] ),
    IF ( HASONEVALUE ( 'Product'[Product Line] ),
        RANKX ( All ( 'Product'[Product Line] ), [Sales Amount] )
    )
)

Ranking.jpg

View solution in original post

Helpful resources

Announcements
Exclusive LIVE Community Event #3 – Ask Arun Anything

Exclusive LIVE Community Event #3 – Ask Arun Anything

Join us in the third Triple A event!

Meet the 2020 Season 1 Power BI Super Users!

Meet the 2020 Season 1 Power BI Super Users!

It’s the start of a new Super User season! Learn all about the new Super Users and brand-new tiered recognition system.

Super User Challenge: Can You Solve These?

Super User Challenge: Can You Solve These?

We're celebrating the start of the New Super User season with our first ever Super User 'Can You Solve These?' challenge.

Power BI Desktop Update - February 2020

Power BI Desktop Update - February 2020

We are super excited for our update this month, as we are releasing two of our top community requests!

Power Platform Online Conference

Power Platform Online Conference

Join us for the first ever Power Platform Online Conference!

Top Solution Authors