Page 1 of 1
Case statement in transformer
Posted: Tue Aug 11, 2015 4:03 pm
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
Re: Case statement in transformer
Posted: Tue Aug 11, 2015 4:16 pm
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.
Posted: Tue Aug 11, 2015 5:18 pm
by ray.wurlod
Seems like a straightforward If..Then..Else expression to me, encapsulating pretty much the logic you already have. Is "-" always present?
Posted: Tue Aug 11, 2015 5:25 pm
by rkashyap
If incoming datatype is numeric then ...
Abs function may also work.
Posted: Tue Aug 11, 2015 7:27 pm
by ray.wurlod
Still need an If..Then..Else to isolate the -12 case.
Posted: Thu Aug 13, 2015 2:12 am
by vinothkumar
How about multiplying the number with -1 to flip the sign wherever required.
Posted: Thu Aug 13, 2015 4:39 am
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