Derived Column Expression Help...

  • Here is my Sample Data

    ID,SID,FNAME

    1,17,SMITH

    2,6,JON

    3,17,NOR

    Here is my destination Columns and condition

    ID,SID,SID2,FNAME

    I want condion in derived column

    IF SID = '17' then insert the value in SID

    IF SID = '6' then insert the value in SID2

    Here is the my final output looks like.

    ID,SID,SID2,FNAME

    1,17,,SMITH

    2,,6,JON

    3,17,,NOR

    Any help?

    Thank You

  • Just to be clear. If SID = 17 then the destination SID gets 17 and SID2 gets empty string or a NULL (if it is a numeric column) and if SID = 6 then desitination SID gets empty string or a NULL (if it is a numeric column) and SID2 gets 6. In my opinion, in your Derived Column transformation you want to have 2 derived columns which would be SID (Replace SID) and SID2 (new column since SID2 doesn't exist in your source). Here are what the expressions would look like:

    SID = [SID]==17?[SID]:NULL(DT_UI4)

    SID2 = [SID]==6?[SID]:NULL(DT_UI4)

    I'm assuming the data in numeric and is coming in as a four-byte unsigned integer (DT_UI4), so setting to NULL which is what NULL(DT_UI4) does. You'd need to change the type being returned by the NULL() function to whatever type you need output.

  • Awesome, it works fine...

    Thank You.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply