Compare values in current row to the values in previous row

One Star

Compare values in current row to the values in previous row

hi,
how do i Compare values in current row to the values in previous row?
Please walk me through the steps.
Thanks
One Star

Re: Compare values in current row to the values in previous row

Hi
Use tJavaRow to store the previous row into several context variables.
When it comes to next row, compare the next row with these context variables.
Regards,
Pedro
One Star

Re: Compare values in current row to the values in previous row

Hi,
You could also use the tMemorizeRows component and configure it to memorize just 1 row. This saves you from writing java code.
Regards,
Arno
One Star

Re: Compare values in current row to the values in previous row

David,
I had a similar requirement in which I was required to add previous row value to consecutive row...
Sr. No | B | C
1 | 1 | 1
2 | 2 | 3
3 | 3 | 5
4 | 4 | 7
See the summation which is performed in C column.
This could be achieved using tJavaRow and one variable
output_row.C = (Integer)globalMap.get("prevRowVal")+input_row.B;
globalMap.put("prevRowVal",output_row.C);
Hope this would help you to implement yours requirement.
Thanks
Vaibhav
One Star

Re: Compare values in current row to the values in previous row

Hi Vaibhav
Thanks for your scenario.
Regards,
Pedro
Seven Stars

Re: Compare values in current row to the values in previous row

Hi ,
I am not able to fetch the previous record from tmemorizerow say for example there is two records in mysql table
on_off |  real_time_clock
0| 2017-01-01 13:00:00
1|2017-01-01 13:15:00

i need to find the difference between the real time clock when on_off changes from 0 to 1 ie 15 minutes ,I dont know how to fetch the previous record from tMemorizeRow and compare it with the current value of on_off .It will be helpful if you say me how to do it.
Thanks,
kasthuri rengan