Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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 :
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
Use a tJavaFlex instad. In the "start code"
int i = 0;
In the "main code" use:
i += row3.val;
row4.bleep = i;
Use a tJavaFlex instad. In the "start code"
int i = 0;
In the "main code" use:
i += row3.val;
row4.bleep = i;
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
In fact, it work only for one distinct ID, but I have some.
My exemple was too simplify for the post 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 |
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;