Hitachi Vantara Pentaho Community Forums
Results 1 to 5 of 5

Thread: Splitting Into Rows Based on Values

  1. #1
    Join Date
    Jun 2012
    Posts
    5

    Default Splitting Into Rows Based on Values

    I couldn't find a really analogous example or discussion anywhere, so I thought I'd throw this out there:

    I'm getting a row of data from an external source that contains a "first" integer value (say, 5) and a "total" integer value (say, 4), like: Blah|Blah|1|4. The remaining fields would remain the same, but I would need 4 separate rows which would read:
    Blah|Blah|1|4
    Blah|Blah|2|4
    Blah|Blah|3|4
    Blah|Blah|4|4

    Thoughts? Only possible via UDJC?

    Thanks,
    Sam

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

    Default

    Quote Originally Posted by spierron View Post
    I'm getting a row of data from an external source that contains a "first" integer value (say, 5) and a "total" integer value (say, 4),
    Where does the 5 fit into your sample?

    Perhaps give us sample incoming and outgoing rows so we can better guide you.
    Perhaps you might also want to look at the Clone Rows step.
    **THIS IS A SIGNATURE - IT GETS POSTED ON (ALMOST) EVERY POST**
    I'm no expert.
    Take my comments at your own risk.

    PDI user since PDI 3.1
    PDI on Windows 7 & Linux

    Please keep in mind (and this may not apply to this thread):
    No forum member is going to do your work for you. We will help you sort out how to do a specific part of the work, as best we can, in the timelines that our work will allow us.
    Signature Updated: 2014-06-30

  3. #3
    Join Date
    Jun 2012
    Posts
    5

    Default

    Quote Originally Posted by gutlez View Post
    Where does the 5 fit into your sample?

    Perhaps give us sample incoming and outgoing rows so we can better guide you.
    Perhaps you might also want to look at the Clone Rows step.
    Whoops!

    That should have been:
    Blah|Blah|5|4

    Resulting in:
    Blah|Blah|5|4
    Blah|Blah|6|4
    Blah|Blah|7|4
    Blah|Blah|8|4

  4. #4
    Join Date
    Jun 2012
    Posts
    5

    Default

    I tested the Clone Rows step...when I checked it out the first time, I didn't quite get it...I think I may have it squared away now by doing some simple addition and subtraction in conjunction with the Clone Rows step. Not exactly elegant, but it definitely seems to work! Thanks!

  5. #5
    Join Date
    Jun 2012
    Posts
    5

    Default

    For posterity, here was my solution:

    -[Whatever data input step to get Field 1 (str), Field 2(str), InitValue (int), TotalValue(int)]
    -Add constant step [Field SingularSensation, Type Integer, Value 1]
    -Calculator step [New field: "cloneRows", Calculation: A-B, FieldA: TotalValue, FieldB: SingularSensation, Value type: Integer]
    -Clone Row step Name:  cloneRowStep.jpg
Views: 24
Size:  43.4 KB
    -Calculator step [New field: "FinalValue", Calculation: A+B, FieldA: InitValue, FieldB: InitValue_1, Value type: Integer]
    -[Whatever data output step to present Field 1 (str), Field 2(str), FinalValue (int), TotalValue(int)]

    I don't see any reason why this wouldn't work perfectly well for any case like this...I smell an intern/jr dev project to create a plugin for contribution for future usage, since I know this is something we'll use all the time, and perhaps others would as well, and a pluign would look a whole lot nicer than this mess.

    Thanks again.

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.