Search code examples
javascriptpentahoetl

Pentaho- if min datetime group by a condition, set another field value to value1


i am newbie to Pentaho...can someone help me with the following problem...

i have the data already sorted like below:

session, log_time, flag

1111, 2017-05-17 11:11:10,0

1111,2017-05-17 11:11:11,0

1111,2017-05-17 11:11:12,0

1111,2017-05-17 11:11:13,0

2222,2017-05-17 11:11:10,0

2222,2017-05-17 11:11:13,0

2222,2017-05-17 11:11:15,0

how can i set the flag value to 1 when it has the minimum log_time group by session? i am hoping the get the result like below:

session, log_time, flag

1111, 2017-05-17 11:11:10,**1**

1111,2017-05-17 11:11:11,0

1111,2017-05-17 11:11:12,0

1111,2017-05-17 11:11:13,0

2222,2017-05-17 11:11:10,**1**

2222,2017-05-17 11:11:13,0

2222,2017-05-17 11:11:15,0

Solution

  • Simply running through an Add value fields changing sequence will give you the following: Add value fields

    Then you can act on only the values that have a "sequence_value" of 1. Note that the step requires sorted input.