Case statement 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
deesh
Participant
Posts: 193
Joined: Mon Oct 08, 2007 2:57 am

Case statement in transformer

Post by deesh »

Hi,

Please explain the situation resolvation

Now i am getting data -1,-12,-13,-1,-1

data started with 1 should be flip sign, if getting '-' should be '+' or '+' should be'-'. except data start with 12, remaining start with 1 should be change.

i have to get the data like +1,-12,+13,+1,+1

How to do in transformer, please provide me the guidance
deesh
Participant
Posts: 193
Joined: Mon Oct 08, 2007 2:57 am

Re: Case statement in transformer

Post by deesh »

Hi i experimented will do with below logic even fine.

( Left(column,1) ='1' and Left(column,2) <>'12')

but looking any other way we can filter.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Seems like a straightforward If..Then..Else expression to me, encapsulating pretty much the logic you already have. Is "-" always present?
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
rkashyap
Premium Member
Premium Member
Posts: 532
Joined: Fri Dec 02, 2011 12:02 pm
Location: Richmond VA

Post by rkashyap »

If incoming datatype is numeric then ... Abs function may also work.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Still need an If..Then..Else to isolate the -12 case.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
vinothkumar
Participant
Posts: 342
Joined: Tue Nov 04, 2008 10:38 am
Location: Chennai, India

Post by vinothkumar »

How about multiplying the number with -1 to flip the sign wherever required.
priyadarshikunal
Premium Member
Premium Member
Posts: 1735
Joined: Thu Mar 01, 2007 5:44 am
Location: Troy, MI

Post by priyadarshikunal »

why you are putting a filter condition when you want to just flip the sign?

Code: Select all

if (column = '-12') then column else (if (left(convert('+-','',column),1) = '1') then column * -1 else column)

if (left(convert('+- ','',column),1) = '1' and (left(convert('+- ','',column),2) <> '12') then column * -1 else column

if (left(abs(column),1) = '1' and (left(abs(column),2) <> '12') then column * -1 else column
Priyadarshi Kunal

Genius may have its limitations, but stupidity is not thus handicapped. :wink:
Post Reply