Hitachi Vantara Pentaho Community Forums
Results 1 to 6 of 6

Thread: Looping through Rows

  1. #1
    Join Date
    Aug 2017
    Posts
    8

    Default Looping through Rows

    Hi,

    How do I loop through the rows in kettle? Here is the goal to be more clear.

    I have a database with 2 fields, Sent Time and Sent By. Sent By consists of "Fred" and "Ben".

    Now the records per row will show:

    12-01-2017 02:15:15 AM Ben
    12-01-2017 02:20:15 AM Fred
    12-01-2017 02:35:15 AM Fred
    12-01-2017 02:45:15 AM Ben


    Now my issue is I want to check first if Sent By is Ben then the next row is Fred, then i subtract the Sent Time of Fred to Sent Time of Ben.
    Then if Sent By is Ben then the next row is still ben then i put the first time stamp of ben in a variable then proceed to check if the next row is Fred. if it is then i subtract the time stamp of Fred to that first sent time by ben. Hope its clear

  2. #2
    Join Date
    Aug 2016
    Posts
    290

    Default

    Quote Originally Posted by Buddy View Post
    Hi,

    How do I loop through the rows in kettle? Here is the goal to be more clear.

    I have a database with 2 fields, Sent Time and Sent By. Sent By consists of "Fred" and "Ben".

    Now the records per row will show:

    12-01-2017 02:15:15 AM Ben
    12-01-2017 02:20:15 AM Fred
    12-01-2017 02:35:15 AM Fred
    12-01-2017 02:45:15 AM Ben


    Now my issue is I want to check first if Sent By is Ben then the next row is Fred, then i subtract the Sent Time of Fred to Sent Time of Ben.
    Then if Sent By is Ben then the next row is still ben then i put the first time stamp of ben in a variable then proceed to check if the next row is Fred. if it is then i subtract the time stamp of Fred to that first sent time by ben. Hope its clear
    This type of logic is particularly difficult to implement in kettle. I suggest using user defined java code and put your login in there.

  3. #3
    Join Date
    Apr 2008
    Posts
    4,696

    Default

    Input -> Analytic Query (retrieve Sent By from prior row) -> Filter Rows (allow rows where Sent By <> Prior Sent By) -> Analytic Query (retrieve Sent Time from prior row) -> Calculator

  4. #4
    Join Date
    Aug 2017
    Posts
    8

    Default

    Wow thanks gutlez, it works just as I want it

  5. #5
    Join Date
    Aug 2016
    Posts
    290

    Default

    Sorry I was badly mistaken, learned something new though!

  6. #6
    Join Date
    Nov 2013
    Posts
    382

    Default

    Quote Originally Posted by Sparkles View Post
    ... learned something new though!
    +1 !!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Privacy Policy | Legal Notices | Safe Harbor Privacy Policy

Copyright © 2005 - 2019 Hitachi Vantara Corporation. All Rights Reserved.