Forum Discussion
StevenT
Helper V
1 year agoCreating 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
- anmolmalviya05
Super User
Hi StevenT,
Please try the below measure:Rank =
RANKX(
ALL('PurchasedFrom'),
CALCULATE(SUM('TrackSales'[SalesAmt])),
DESC,
DENSE
)
- StevenT
Helper V
Thanks very much for your help!
- johnt75
Super User
Try
Ranking = VAR PurchasedFromWithSales = ADDCOLUMNS ( ALLSELECTED ( 'PurchasedFrom'[pkPurchasedFrom] ), "@sales", CALCULATE ( SUM ( 'TrackSales'[SalesAmt] ) ) ) VAR Result = RANK ( DENSE, PurchasedFromWithSales, ORDERBY ( [@sales], DESC ) ) RETURN Result