Forum Discussion

StevenT's avatar
StevenT
Icon for Helper V rankHelper V
1 year ago
Solved

Creating Rank

hI, I'm having trouble creating rank for my data.

Here's the table I'm using.|
Here's the DAX measure I created. 

   
 RANKX(ALL('PurchasedFrom'),'PurchasedFrom'[pkPurchasedFrom],SUM('TrackSales'[SalesAmt]),DESC,Dense)


I'm sure I made a mistake in the code but not sure what.
PurchasedFrom table is linked to trackList and SalesAmt is also linked to TrackList.
Tracklist contains millions of records and so the $ is accurate but I just can't get the Ranking to work properly.

 

  • Hi StevenT,
    Please try the below measure:

    Rank =

    RANKX(

    ALL('PurchasedFrom'),

    CALCULATE(SUM('TrackSales'[SalesAmt])),

    DESC,

    DENSE

    )

     

  • Try

    Ranking =
    VAR PurchasedFromWithSales =
        ADDCOLUMNS (
            ALLSELECTED ( 'PurchasedFrom'[pkPurchasedFrom] ),
            "@sales", CALCULATE ( SUM ( 'TrackSales'[SalesAmt] ) )
        )
    VAR Result =
        RANK ( DENSE, PurchasedFromWithSales, ORDERBY ( [@sales], DESC ) )
    RETURN
        Result
    

3 Replies

  • Hi StevenT,
    Please try the below measure:

    Rank =

    RANKX(

    ALL('PurchasedFrom'),

    CALCULATE(SUM('TrackSales'[SalesAmt])),

    DESC,

    DENSE

    )

     

  • Try

    Ranking =
    VAR PurchasedFromWithSales =
        ADDCOLUMNS (
            ALLSELECTED ( 'PurchasedFrom'[pkPurchasedFrom] ),
            "@sales", CALCULATE ( SUM ( 'TrackSales'[SalesAmt] ) )
        )
    VAR Result =
        RANK ( DENSE, PurchasedFromWithSales, ORDERBY ( [@sales], DESC ) )
    RETURN
        Result