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: 
Slope
Contributor III
Contributor III

How to make a cumulate tJavaRow

Hello,

 

I'm back with a new problem on a "cumulative" workflow.

This one seems easy, but I'm stuck since a day on it.

 

Here's the source :

 

ID Val
1 2
1 6
1 1
1 3
1 4
1 3
1 2

 

Here's what I would like :

 

ID Val **bleep**
1 2 2
1 6 8
1 1 9
1 3 12
1 4 16
1 3 19
1 2 21

 

Currently I had the column ID and Val, and I'm trying to find a way to have the "**bleep**".

 

Currently, I've this :

 

0683p000009MA7d.jpg

 

I use on the tMap two variable, one "cum_this" and the other one "cum_last".

Cum_this is the current value, Cum_last equals to the previous value of Cum_this.

 

Then, I tried on the tJavaRow to use a globalMap variable, wich equal "Cum_last", I tried to apply the same process than this post :

 

https://community.talend.com/t5/Design-and-Development/How-to-Perform-Cumulative-in-Talend/m-p/36486

 

But, on my side, when I set like :

 

 

if((Integer)globalMap.get(Integer.toString(row32.deptno)) != null){
	
}

 

 

It's always null.

 

So here's where I'm, if you have any tips, don't hesitate 0683p000009MAB6.png

Labels (2)
1 Solution

Accepted Solutions
billimmer
Creator III
Creator III

Use a tJavaFlex instad.  In the "start code"

 

int i = 0;

 

In the "main code" use:

 

i += row3.val;
row4.bleep = i;

View solution in original post

4 Replies
billimmer
Creator III
Creator III

Use a tJavaFlex instad.  In the "start code"

 

int i = 0;

 

In the "main code" use:

 

i += row3.val;
row4.bleep = i;

Slope
Contributor III
Contributor III
Author

Hello,

 

Yes it work with a tjavaFlex instead of a tjavaRow, I did it last night.

I never use tjavaFlex before, I'll have a look on it now to understand what's the difference with a tjavaRow.

 

Thanks for your reply,

Kind regards

Slope
Contributor III
Contributor III
Author

In fact, it work only for one distinct ID, but I have some.

 

My exemple was too simplify for the post 0683p000009MACn.png here's another one :

 

 

ID Val **bleep**
1 2 2
1 6 8
1 1 9
1 3 12
1 4 16
1 3 19
1 2 21
2 3 3
2 2 5
2 7 12
2 5 17
2 1 18
billimmer
Creator III
Creator III

in the "start code" of the tJavaFlex also store the ID.  

 

int i = 0;

int lastID = row3.id;

 

Then in the "main code" check to see if the lastID is the same or different.  If it's the same then add to "i", if it's different, then set "i" to the current value.

 

if(row3.id==lastID) {

i += row3.val;

} else {

i = row3.val;

row4.bleep = i;