Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I need to do a cumulative sum in the resident table as follows
tab1
a, b, c, d
a, 201101, 1, 0
a, 201101, 1, 1
a, 201102, 1, 1
b, 201101, 1, 0
b, 201102, 1, 1
c, 201101, 1, 0
c, 201102, 1, 0
result
a, b, c, d, e, f
a, 201101, 1, 0, 1, 0
a, 201101, 1, 1, 2, 1
a, 201102, 1, 1, 3, 2
b, 201101, 1, 0, 1, 0
b, 201102, 1, 1, 2, 1
c, 201101, 1, 0, 1, 0
c, 201102, 1, 0, 2, 0
Hi Robson,
You can see the attached example.
I hope is what you want.
Best regards.
Ri Robson,
I think it could look like this
Load *,
if(peek(a) =a, peek(e)+c,c) as e,
if(peek(a) =a, peek(f)+d,d) as f
resident tab1 order by a ASC, b ASC;
i.e. order your Input table by a, b ascending (like in your example, but force it).
Check if first column value is identical to previous value, then sum up, else (first appearance of value) start with initial value.
I hope I understood your requirement,
Stefan
Hi Robson,
You can see the attached example.
I hope is what you want.
Best regards.
Thanks guys!