Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.
Originally posted by: J.LimHi there,
Was wondering if anyone can give me a hand on this:
CustomerNbr Date Hour Value
1 15/3 15 100
1 15/3 16 80
1 15/3 17 90
2 15/3 10 20
2 15/3 18 10
What I'm hoping to get is the difference of value in current row's value compared to prev row's value, and the difference should be 0 when it is first in group sorted by customerNbr, Date, Hour, ie end results should look like:
CustomerNbr Date Hour Value Difference
1 15/3 15 100 0
1 15/3 16 80 -20
1 15/3 17 90 10
2 15/3 10 20 0
2 15/3 18 10 -10
I have something like this, but was stuck where it always retrieve prev row's value as the first value in the group.
if firstInGroup
then
{
ValueDifference = 0
tempValue = 'Value'
}
else
prevValue = tempValue
ValueDifference = 'Value' - prevValue
emit *, tempValue, prevValue, ValueDifference
Anyone who can assist with this question would be much appreciated!
Thanks, Jess