Hitachi Vantara Pentaho Community Forums
Results 1 to 6 of 6

Thread: So Simple Yet...... Replace data in one column with data in another

  1. #1
    Join Date
    Apr 2008
    Posts
    123

    Default So Simple Yet...... Replace data in one column with data in another

    Surely this is easier than I am making it. I just want to:

    Replace data in column A with data from column B. If there is no data in column B then leave the data in Column A.


    Thanks in advance for showing my how easy this is.....

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

    Default

    I have only been able to figure out how to do it with JavaScript.

    Code:
    *** PSEUDO CODE ONLY ***
    *** Could not find actual production code ***
    if ( columnB is not null )
    {
      newA = columnB
    } else {
      newA = columnA
    }

  3. #3
    Join Date
    Jul 2009
    Posts
    24

    Default Possible Non-JavaScript alternative

    You might try using a filter step to determine if there is data in column B. If the data exists in B you can send the flow to a Calculator to copy the contents and remove the original column A. The other filter desitination would simply pass the information along and may use a Select to remove column B.

  4. #4
    DEinspanjer Guest

    Default

    You can do this through the calculator step. Unfortunately, unless you happen to be familiar with Oracle, you wouldn't know because the name of the function you want to use is NVL(a,b).

    NVL is similar to the COALESCE function in other databases. If value "a" is null then it will use the value "b".

    Since the Calculator step doesn't support field replacement yet, you'll need to make a new field and then use it or if you need the field to have the same name, make a new field with a temporary name and then use a select values step to remove the old field and rename the new one.

  5. #5
    Join Date
    Apr 2008
    Posts
    123

    Default

    Thank you. Perhaps this should be its own step.....

  6. #6
    Join Date
    Nov 1999
    Posts
    9,729

    Default

    There is an experimental step called "Set field value" in 3.2.
    However, there really isn't a good use-case for it since just about every step allows you to map field values to a target.

    As such, it's just as easy to create a new field.

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.