Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to run accumulated calculation in load script with 2 dimensions?

I’m using this for accumulating 1 dimension (Date) ,

test1:

load

CalendarDate,

country,

DailySales,

If(RowNo() = 1, DailySales, Peek('AccumulatedSales') + DailySales) AS AccumulatedSales

resident test;

you can see that the accumulation is made for the date excluding the country. (you see below only sample of the data)

how can I adjust it to 2 dimensions?

Thanks.

Date

country

DailySales

AccumulatedSales

7/24/2013

Afghanistan - AF

7

34794

7/24/2013

Albania - AL

1

34824

7/23/2013

Afghanistan - AF

0

34787

7/23/2013

Albania - AL

3

34823

7/22/2013

Afghanistan - AF

5

34787

7/22/2013

Albania - AL

1

34820

7/21/2013

Afghanistan - AF

9

34782

7/21/2013

Albania - AL

1

34819

7/20/2013

Afghanistan - AF

10

34773

7/20/2013

Albania - AL

0

34818

7/19/2013

Afghanistan - AF

10

34763

7/19/2013

Albania - AL

1

34818

7/18/2013

Afghanistan - AF

7

34753

7/18/2013

Albania - AL

0

34817

7/17/2013

Afghanistan - AF

13

34746

7/17/2013

Albania - AL

1

34817

7/16/2013

Afghanistan - AF

17

34733

7/16/2013

Albania - AL

2

34816

7/15/2013

Afghanistan - AF

54

34716

7/15/2013

Albania - AL

20

34814

1 Solution

Accepted Solutions
lironbaram
Partner - Master III
Partner - Master III

test1:

load

CalendarDate,

country,

DailySales,

If(country<>previous(country), DailySales, Peek('AccumulatedSales') + DailySales) AS AccumulatedSales

resident test

order by country CalendarDate;

this will accumulate the sales for each country by date

View solution in original post

3 Replies
Anonymous
Not applicable
Author

Have a look at this post: http://community.qlik.com/message/100042#100042

Jonathan

lironbaram
Partner - Master III
Partner - Master III

test1:

load

CalendarDate,

country,

DailySales,

If(country<>previous(country), DailySales, Peek('AccumulatedSales') + DailySales) AS AccumulatedSales

resident test

order by country CalendarDate;

this will accumulate the sales for each country by date

Not applicable
Author

If(country=revious(country), DailySales, Peek('AccumulatedSales') + DailySales) AS AccumulatedSales

thanks