Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Accumulation in Load

Hi

To avoid having to use above() excessively in my formulas I tried to accumulate my numbers in the load command. As the previous() however is always looking into the source table the following code does not work

Normal:
LOAD * INLINE [
dim, mycount
1, 3
1, 1
1, 4
2, 7
2, 18
2, 1
];

Accumulated:
LOAD dim
, if(previous(dim)=dim,previous(mycume)+mycount,mycount) as mycume
RESIDENT Normal;

and the following is only the sum of the current and above row

Accumulated:
LOAD dim
, if(previous(dim)=dim,previous(mycount)+mycount,mycount) as mycume
RESIDENT Normal;

Juerg

1 Solution

Accepted Solutions
Not applicable
Author

HI,

I`m not sure i have understood your question.

can elaborate a bit. since i have tried to reproduce your scenario. it worked as i expected.

Below is my code

Accu:



LOAD

* INLINE

[

;



Noconcatenate

Accu_Temp:



Load

* Resident Accu order by dim

Asc;

Drop

Table

Accu;



Load

dim, if(peek(dim) = dim, peek(mycount_new)+mycount,mycount) as mycount_new,mycount

Resident

Accu_Temp;

Drop

Table

Accu_Temp;









View solution in original post

1 Reply
Not applicable
Author

HI,

I`m not sure i have understood your question.

can elaborate a bit. since i have tried to reproduce your scenario. it worked as i expected.

Below is my code

Accu:



LOAD

* INLINE

[

;



Noconcatenate

Accu_Temp:



Load

* Resident Accu order by dim

Asc;

Drop

Table

Accu;



Load

dim, if(peek(dim) = dim, peek(mycount_new)+mycount,mycount) as mycount_new,mycount

Resident

Accu_Temp;

Drop

Table

Accu_Temp;