Forum Discussion

peterpan's avatar
peterpan
Helper I
1 year ago
Solved

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...
  • Royel's avatar
    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!