Forum Discussion
peterpan
1 year agoHelper I
Rankx Issue: Resulting in Incorrect Figures
I am trying to create a ranking measure to show customer code is ranked from highest to lowest sales where there is a growth is sales as compared to last year. I have used following measure- VAR...
- 1 year ago
Hi, peterpan Thanks for asking question.
Seems like you have some issues with DAX. FltrTbl contains only customers with positive growth.
However, when the visual is on a customer with negative growth, RANKX still takes that customer’s [Total Sales] and ranks it against the positive-growth set , so you still get a rank instead of BLANK. That’s why rows like SalesGrowth% = -6% show a rank.
You can try this dax, at first it will filter all positive growth items then do the ranking
Rank Among Positives := IF( [SalesGrowth%] > 0, RANKX( FILTER( ALLSELECTED(DimCustomer[Customer Code]), [SalesGrowth%] > 0 ), [Total Sales], , DESC, DENSE ) )Find this helpful? ✔ Give a Kudo • Mark as Solution – help others too!
Ashish_Mathur
1 year agoSuper User
Hi,
Try this measure
=if([SalesGrowth%]<0,blank(),rank(dense,filter(all(dimcustomer[Customer code]),[SalesGrowth%]>0),orderby([Total sales],desc)))
Hope this helps.