Page 1 of 1

If then else logic in transformer

Posted: Fri Aug 06, 2010 7:43 pm
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...

Posted: Fri Aug 06, 2010 8:02 pm
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'

Posted: Sat Aug 07, 2010 1:52 am
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' .......

Posted: Sat Aug 07, 2010 4:31 am
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).

Posted: Sat Aug 07, 2010 7:13 am
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.