Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I have the following data:
ID | Time | Value |
A | 26 | 100 |
A | 27 | 110 |
A | 28 | 120 |
B | 1 | 50 |
B | 2 | 60 |
B | 3 | 70 |
C | 12 | 200 |
C | 13 | 210 |
C | 14 | 190 |
And I'd like to transform it into:
ID | Time 1 | Time 2 | Time 3 |
A | 100 | 110 | 120 |
B | 50 | 60 | 70 |
C | 200 | 210 | 190 |
Where Time 1, Time 2, and Time 3 are the first, second, and third max Time per ID. So for ID of A, Time 28 is Time 1. Time 27 is Time 2, etc
I've tried:
Time 1 = Sum({<Time={$(=Max(Time, 1))}>} Value)
Time 2 = Sum({<Time={$(=Max(Time, 2))}>} Value)
Time 3 = Sum({<Time={$(=Max(Time, 3))}>} Value)
May be this
FirstSortedValue(Aggr(Sum(Value), ID, Time), -Aggr(Time, ID, Time), 1)
FirstSortedValue(Aggr(Sum(Value), ID, Time), -Aggr(Time, ID, Time), 2)
FirstSortedValue(Aggr(Sum(Value), ID, Time), -Aggr(Time, ID, Time), 3)