Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
Leverage your QlikView investment to modernize BI – see how! Join Group
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Contributor III
Contributor III

Cumulative Sum of amount based on id & path id

 

Hi All,

 

I have data like below, Can anyone suggest how I can achieve output below? basically it's sum of amount w.r.t. path and Id.

Please help on this.

   

Id Path Amount
161000
1121000
1182000
1241000
261000
2122000
2180
2240
361000
3123000
3181000
3240

 

Output-

   

Id Path Amount SUM(Amount)
1610001000
11210002000
11820004000
12410005000
2610001000
21220003000
21803000
22403000
3610001000
31230004000
31810005000
32405000

 

1 Solution

Accepted Solutions
Highlighted
Creator III
Creator III

Re: Cumulative Sum of amount based on id & path id

Hi,

You can do something like this in your script:

Table1:

LOAD if(Peek(Id)=Id,Amount+Peek(AmountAcumulated),Amount) as AmountAcumulated,

* INLINE [

Id, Path, Amount

1, 6, 1000

1, 12, 1000

1, 18, 2000

1, 24, 1000

2, 6, 1000

2, 12, 2000

2, 18, 0

2, 24, 0

3, 6, 1000

3, 12, 3000

3, 18, 1000

3, 24, 0

];

View solution in original post

4 Replies
Highlighted
Champion
Champion

Re: Cumulative Sum of amount based on id & path id

Hi,

try this:

=RangeSum(Above(Amount,0,rowno()))

Highlighted
Creator III
Creator III

Re: Cumulative Sum of amount based on id & path id

Hi,

You can do something like this in your script:

Table1:

LOAD if(Peek(Id)=Id,Amount+Peek(AmountAcumulated),Amount) as AmountAcumulated,

* INLINE [

Id, Path, Amount

1, 6, 1000

1, 12, 1000

1, 18, 2000

1, 24, 1000

2, 6, 1000

2, 12, 2000

2, 18, 0

2, 24, 0

3, 6, 1000

3, 12, 3000

3, 18, 1000

3, 24, 0

];

View solution in original post

Highlighted
Contributor III
Contributor III

Re: Cumulative Sum of amount based on id & path id

Brilliant Jaume Criballés Faja ! Thanks a lot for quick solution.

Highlighted
Master
Master

Re: Cumulative Sum of amount based on id & path id

Try this as your expression

=if(Id=Above(Id),RangeSum(Above(sum(Amount),0,RowNo(TOTAL))),sum(Amount))