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.

Not applicable

Cumulative Quantity in the script

Hello,

I am trying to create a cumulative total within the script and I can't recall how to do it. Essentially I want to create a new field to show the rolling total for the year, see the below example. I can do it within a chart but require it to be added as a new field in the script.

Thanks in advance,

Ralph

WeekQty

Rolling Qty

13030
23262
345107
470177
531208
Tags (2)
1 Solution

Accepted Solutions
MVP & Luminary
MVP & Luminary

Re: Cumulative Quantity in the script

try:

Load *, if(rowno()=1,Qty,Peek(RollingQty)+Qty) AS RollingQty

Inline [

Week,Qty

1,30

2,32

3,45

4,70

5,31];


talk is cheap, supply exceeds demand
5 Replies

Re: Cumulative Quantity in the script

Check with this

Load *, (Alt(Previous(RollingQty),0)+Qty) AS RollingQty;

Load * Inline [

Week,Qty

1,30

2,32

3,45

4,70

5,31];

Not applicable

Re: Cumulative Quantity in the script

Hello,

I get a field not found error for RollingQty. For clarity in my example I want to create the Rolling Qty field, currently I only have week and Qty.

Thanks,

Ralph

MVP & Luminary
MVP & Luminary

Re: Cumulative Quantity in the script

try:

Load *, if(rowno()=1,Qty,Peek(RollingQty)+Qty) AS RollingQty

Inline [

Week,Qty

1,30

2,32

3,45

4,70

5,31];


talk is cheap, supply exceeds demand
Not applicable

Re: Cumulative Quantity in the script

That works brilliant.

Thanks,

Ralph

Re: Cumulative Quantity in the script

Hi,

Check with this

Load *, (Alt(Peek('RollingQty'),0)+Qty) AS RollingQty;

Load * Inline [

Week,Qty

1,30

2,32

3,45

4,70

5,31];