Reputation: 23
I am using AdventureWorks DB and I want to rank the resellers by their total sale amount. So basically the table looks like this:
I used the following measure to rank it:
Rank Reseller = RANKX(ALL(ResellerSales), MAX(ResellerSales[SalesAmount]),,1)
But it returns only 1 as the rank.
I followed these two videos:
https://www.youtube.com/watch?v=z2qzJVeYhTY
and
https://www.youtube.com/watch?v=SsZseKOgrWQ&t=603s
but I can't understand what is wrong!
Upvotes: 0
Views: 5847
Reputation: 3659
This has to do with the current scope that Rankx evaluates de Aggregation.
Try wrapping your aggregation with CALCULATE, and you probably want the SUM not the MAX:
Rank Reseller = RANKX(ALL(ResellerSales), CALCULATE(SUM(ResellerSales[SalesAmount])))
You can create a Measure like so, and use it on RANKX, since it is a measure it will work without explicitly adding the CALCULATE:
Sales Amount = SUM(ResellerSales[SalesAmount])
Rank Reseller = RANKX(ALL(ResellerSales), [Sales Amount])
EDIT:
Rank Reseller = RANKX(ALL('ResellerSales'[Resellerkey]), [Sales Amount])
Try it like this.
Upvotes: 1
Reputation: 1781
To rank the [ReSellerkey] by [SalesAmount] you'd want to do something like this:
Rank Sales Amount :=
RANKX(
'Table',
'Table'[SalesAmount],
,
ASC,
Dense
)
Upvotes: 0