Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
gkcchowdary
Creator
Creator

Accumulate and cumulative expression in script level and chat level?

Hi

I have sample data like

I'd,   product,    sales

1,  a,   10

2,  b,   20

3,  c,   30

4,  d,  40

My required output

I'd,  product,   sales, accumulate

1,  a,   10, 10

2, b,    20, 30

3, c,   30,  50

4, d,   40 ,70

How to write the expression in script level and chat level also.

Please help.

Thanks

1 Solution

Accepted Solutions
jaumecf23
Creator III
Creator III

Hi,

Try the following code:

Table1:

LOAD

if(isnull(Peek(sales)),sales,Peek(sales) + sales) AS accumulate,

* INLINE [

I'd,   product,    sales

1,  a,   10

2,  b,   20

3,  c,   30

4,  d,  40

];

View solution in original post

3 Replies
jaumecf23
Creator III
Creator III

Hi,

Try the following code:

Table1:

LOAD

if(isnull(Peek(sales)),sales,Peek(sales) + sales) AS accumulate,

* INLINE [

I'd,   product,    sales

1,  a,   10

2,  b,   20

3,  c,   30

4,  d,  40

];

bhaskar_sm
Partner - Creator III
Partner - Creator III

Hi,

Please find attached the Qvw and solution script.

sum.PNG

LOAD *, Sales + if(recno()=1,0,Previous(Sales)) as Salesf ;

LOAD * inline [

I'd, product, Sales

1,  a,   10

2,  b,   20

3,  c,   30

4,  d,  40

];

if you found this helpful, please mark helpful or correct.

Regards,

Bhasker Kumar

gkcchowdary
Creator
Creator
Author

Hi Bhasker both are working fine.

Do you know how to write the expression using  range sum function .