Java Snippet - values based previous row

Hello all,

is possible to make operation in Java Snipper, which returns value based on value in previous row and in the same or another column? 

UseCase:

I have table with Customer_ID, Order_id and Order_date columns and I want to fill Order_of_orders according to order of orders scpecific for each customer.  

Example of table:

Customer_ID Order_id Order_date Order_of_orders
1 1004 01/06/2016 1
2 1001 01/01/2016 1
2 1006 01/10/2016 2
2 1007 01/11/2016 3
3 1003 01/06/2016 1
4 1002 01/04/2016 1
4 1005 01/10/2016 2

I know how to logically solve this  as I already did in other ETL tool with has Java sripting node, but I can´t find proper syntax for KNIME Java Snippet node.

Thanks you very much for any help:)

1 Like

Hi Jiří 

You can either define a global variable in the snippet and keep track of the previous value using it, or use a lag column node to move the previous value into a new column in the same row

Attached is a workflow example for both

David

 

 

 

Hi David,

thx for advice, should solve my problem :)

Jiří