Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Cumulative Sum in Load

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

1 Solution

Accepted Solutions
Not applicable
Author

Hi Robson,

You can see the attached example.

I hope is what you want.

Best regards.

View solution in original post

3 Replies
swuehl
MVP
MVP

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

Not applicable
Author

Hi Robson,

You can see the attached example.

I hope is what you want.

Best regards.

Not applicable
Author

Thanks guys!