Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements

Breathe easy -- you now have more time to plan your next steps with Qlik!
QlikView 11.2 Extended Support is now valid through December 31, 2020. Click here for more information.

pzwonford
Not applicable

Cumulative sum

Hi guys,

I have the following

  

NamePurchase amountPurchase date
Bob501/01/2016
Bob501/10/2016
Bob1001/02/2016
Ed201/08/2016
Sid501/08/2016

Is there any way in my load script i can have a cumulative sum on purchase amount so the table ends up looking like this

 

NamePurchase amount
Bob20
Ed2
Sid5
1 Solution

Accepted Solutions
richard_chilvers
Not applicable

Re: Cumulative sum

I suggest you use the GROUP BY feature in the load (check it out in the documentation.

It will be along the lines of:

LOAD Name, SUM([Purchase Amount]) as Total_Purchase

FROM ....................

GROUP BY Name;

Of course, in your example, this would give Bob a total of 20.

Do you need something different ?

3 Replies
richard_chilvers
Not applicable

Re: Cumulative sum

I suggest you use the GROUP BY feature in the load (check it out in the documentation.

It will be along the lines of:

LOAD Name, SUM([Purchase Amount]) as Total_Purchase

FROM ....................

GROUP BY Name;

Of course, in your example, this would give Bob a total of 20.

Do you need something different ?

Gysbert_Wassenaar
Not applicable

Re: Cumulative sum

LOAD

     Name,

     Sum([Purchase amount]) as [Purchase amount]

GROUP BY

     Name;

LOAD DISTINCT * INLINE [

Name,Purchase amountPurchase date
Bob,5,01/01/2016
Bob,5,01/10/2016
Bob,10,01/02/2016
Ed,2,01/08/2016
Sid,5,01/08/2016

];


talk is cheap, supply exceeds demand
qlikview979
Not applicable

Re: Cumulative sum

Hi Paul,

In your table  "Bob" having sum 20 like (10+5+5). how you calculated 15?


Regards