I've been using the running total and it seems to work great. My issue, however, is when there are ties.
I've tweaked the example to reflect that and I'm curious if you would know how to approach this problem so that the number you get is actually the same. Changes are highlighted below:
Input:
Customer ID / Product / Num
12345 / Widget 1 / 999
12345 / Widget 2 / 750
12345 / Widget 3 / 750
12346 / Widget 1 / 99
12346 / Widget 4 / 25
12347 / Widget 4 / 56
12347 / Widget 5 / 25
Desired Output:
Customer ID / Product / Num / Rank
12345 / Widget 1 / 999 / 1
12345 / Widget 2 / 750 / 2
12345 / Widget 3 / 750 / 2
12346 / Widget 1 / 99 / 1
12346 / Widget 4 / 25 / 2
12347 / Widget 4 / 56 / 1
12347 / Widget 5 / 25 / 2
Multi-row formula worked for me.. thanks!
The Multi-Row formula required an IF statement that considered both CustomerID and Num.
It also needed an additional "ELSEIF" statement that considered only CustomerID.
Below (and attached) is my solution:
//If the IDs of current & previous row are the same, AND the Num of widgets between current & previous row are the same, then do NOT increment the rank (no "+1")
IF [CustomerID] == [Row-1:CustomerID]
AND [Num] == [Row-1:Num]
THEN [Row-1:RankDense]
//Else, if the IDs of current & previous row are the same (& implicit, Num of widgets is not), then increment rank by 1 ("+1")
ELSEIF [CustomerID] == [Row-1:CustomerID]
THEN [Row-1:RankDense]+1
//Else, assign value of 1.
ELSE 1
ENDIF
Cheers!
Sorry to resurrect a pretty old thread, but I'm trying to find a way of doing this exact same thing, but ranking highest to lowest, rather than lowest to highest.
I've got various Categories with an varied number of transactions in each, and I need to get hold of just the two most recent within each category. As far as I can tell, the best way of doing this would be to rank the transactions, by category and by date from high to low, then filter on ranks 1 and 2 for each Category ID.
Any suggesions?
User | Count |
---|---|
19 | |
15 | |
13 | |
9 | |
8 |