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

Announcements
Discover how organizations are unlocking new revenue streams: Watch here
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

How to get the sum of before rows in talend?

Hi team,

My source table is like

 

0683p000009LrxI.jpg,

I want to add the previous row sal to current like ,

0683p000009Lruc.jpg

How can i achieve the above scenario 

Thanks in advance

 

Labels (1)
1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

If I understand you correctly, you can do this with a tMap and tMap variables. Take a look at the screen shot below. 0683p000009Lrzl.png

I have set up a variable which carries out an accumulation calculation. It is created by clicking the green + at the center top of the tMap. I used a Double (class, not primitive type....essentially I just clicked the tick box next to the "Type" column) and added the following expression....

 

Var.sal_accumulator==null ? row1.sal : Var.sal_accumulator + row1.sal 

Since the tMap variables store values between rows, this make this calculation very easy.

View solution in original post

3 Replies
TRF
Champion II
Champion II

Hi,

 

You should have a look on tMemorizeRows component.

Anonymous
Not applicable
Author

If I understand you correctly, you can do this with a tMap and tMap variables. Take a look at the screen shot below. 0683p000009Lrzl.png

I have set up a variable which carries out an accumulation calculation. It is created by clicking the green + at the center top of the tMap. I used a Double (class, not primitive type....essentially I just clicked the tick box next to the "Type" column) and added the following expression....

 

Var.sal_accumulator==null ? row1.sal : Var.sal_accumulator + row1.sal 

Since the tMap variables store values between rows, this make this calculation very easy.

TRF
Champion II
Champion II

In my opinion, @rhall's solution is better but a little bit more tricky than the solution I proposed using tMemorizeRows.