# QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
On May 18th at 10AM EDT we will answer your QlikView questions live. REGISTER
cancel
Showing results for
Did you mean:
Contributor III

## How to Calculate Accumulative sum for Separate products with Script?

I have a table, I need to show the cumulative sum of the 'Total' column for each products. For example: If i select product 'B' then i should the get the cumulative sum of Product B alone with respective date. i.e 15+2+3=20 not 47+49+52.

I need Output as Below.

Not Like this

1 Solution

Accepted Solutions
MVP

May be like this

Product,

Quantity,

If(Product = Previous(Product), RangeSum(Peek('Total'), Quantity), Quantity) as Total

Resident ....

Order By Product, Date Asc;

10 Replies
MVP

May be like this

Product,

Quantity,

If(Product = Previous(Product), RangeSum(Peek('Total'), Quantity), Quantity) as Total

Resident ....

Order By Product, Date Asc;

Master

plz try this

T:LOAD *,Date#(Date,'DD-MM-YYYY') as Date_N INLINE [

Date, Product, Quantity

10-12-2015, A, 1

11-12-2015, A, 2

12-12-2015, A, 3

13-12-2015, A, 4

14-12-2015, B, 3

15-12-2015, B, 5

16-12-2015, B, 6

17-12-2015, C, 10

19-12-2015, C, 12

];

load *, if(rowno()=1, Quantity, if(Product = Previous(Product), RangeSum(Quantity, Peek(Total)),Quantity))as Total

Resident T

order by Product, Date_N asc

;

MVP

Do we really need RowNo() = 1 check? Product will not be equal to Previous(Product) which you already gives Quantity, why add the RowNo() condition

Master

Sorry bro

MVP

no sorry needed, just fyi

Contributor III
Author

Contributor III
Author

Thanks bro

Master II

Just one more approach

Product,

Quantity,

If(Product = Previous(Product), Peek('Total')+ Quantity, Quantity) as Total

Resident Table

order by Product, Date asc;

Br,

KC

Best Regards,
KC
Contributor III
Author