Compare current and previous row in Java Knime

I am using the java snippet (simple) node. I want to compare the current and just the previous row value. How do I do that?
Like if table is
Row Header
1 A
2 A
3 B
4 C
5 D

When I am in row 2, I want to compare it with row 1, when in row 4, want to compare with row 3 and son on.
Please help!!

1 Like

Hi @sujitnath84 and welcome to KNIME Forum

Did you try the Lag Column node?
gr. Hans


Yes, tried that now. seems to work.
In Java, there’s no way to reference the previous node? As even if I create an array of the row, it will treat individual row of that column as one array element and it wont go ahead of a[0].
Seems, it works in a much different way than traditional java.

1 Like

It’s possible, though rather crude. I suggest to have a look here:


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.