If then else logic in transformer

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
developeretl
Participant
Posts: 89
Joined: Sat Jul 24, 2010 11:33 pm

If then else logic in transformer

Post by developeretl »

Hi,
I need to do transformation with if then else condition..... iam having input column with codes 1,2,3,4,5,6,7
I need to populate the " ab" if the input code 1,2,3 and if it is 4 ,5 then "cd" and if it is 6 ,7 then "ef"
i tried by writing if then else logic for every code. Can you please guide me with simple way of implementing the logic...
kris007
Charter Member
Charter Member
Posts: 1102
Joined: Tue Jan 24, 2006 5:38 pm
Location: Riverside, RI

Post by kris007 »

The simplest is writing the If Then Else with the output values that are related to less number of input columns.

Code: Select all

If InputColumn = 6 Or InputColumn = 7 Then 'ef' Else If InputColumn = 4 Or InputColumn = 5 Then 'cd' Else 'ab'
Kris

Where's the "Any" key?-Homer Simpson
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

You can try something like

Code: Select all

If Index('|':yourField : '|', '|1|2|3|') > 0 Then 'ab' Else .......
Alternatively you can try

Code: Select all

If yourField > 5 Then 'ef' Else If yourField > 3 Then 'cd' .......
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Code: Select all

Field("ab|ab|ab|cd|cd|ef|ef", "|", InLink.TheValue, 1)
Or use a lookup table in a Modify stage (lookup_string_from_int16() function).
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

... or just stick with the if-then-else logic posted. :wink:

Only other thing you might want to account for are values outside the 1-7 range. Justin Case.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply