Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
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
1 Solution

Accepted Solutions
Gysbert_Wassenaar

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

View solution in original post

5 Replies
CELAMBARASAN
Partner - Champion
Partner - Champion

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
Author

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

Gysbert_Wassenaar

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
Author

That works brilliant.

Thanks,

Ralph

CELAMBARASAN
Partner - Champion
Partner - Champion

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];