How to convert negative values into positive

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
vemisr
Participant
Posts: 72
Joined: Thu Sep 11, 2008 1:31 pm

How to convert negative values into positive

Post by vemisr »

Hi Experts,

i have few negative values and positive values in few columns, i need to convert them into positive.

i.e

-75555123 this need to be 75555123
555124 should be 555124


is there any function. i was tried with Abs() but i didn't get any conversions.

Thanks
Vemisr
anbu
Premium Member
Premium Member
Posts: 596
Joined: Sat Feb 18, 2006 2:25 am
Location: india

Post by anbu »

Abs function should work. What did you get?
You are the creator of your destiny - Swami Vivekananda
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

How exactly did you use it? That is what you want after all, the absolute value.
-craig

"You can never have too many knives" -- Logan Nine Fingers
sridinesh2009
Participant
Posts: 14
Joined: Wed Nov 11, 2009 4:52 am
Location: New York

Post by sridinesh2009 »

chulett wrote:How exactly did you use it? That is what you want after all, the absolute value. ...
you can use fabs function...it converts negative to positive
Dinesh.D
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

Or write one yourself as

Code: Select all

  If yourField < 0 Then yourField * (-1) Else yourField
mayura
Participant
Posts: 40
Joined: Fri Aug 01, 2008 5:58 am
Location: Mumbai

Post by mayura »

Sainath.Srinivasan wrote:Or write one yourself as

Code: Select all

  If yourField < 0 Then yourField * (-1) Else yourField
...
or use field function to convert all negative sign to positve and then load into target :idea:
Mayura
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

mayura wrote:
Sainath.Srinivasan wrote:Or write one yourself as

Code: Select all

  If yourField < 0 Then yourField * (-1) Else yourField
...
or use field function to convert all negative sign to positve and then load into target :idea:
Don't take me wrong...what does a field function go to do here ?
Sreenivasulu
Premium Member
Premium Member
Posts: 892
Joined: Thu Oct 16, 2003 5:18 am

Post by Sreenivasulu »

Mayura is suggesting an additional solution :)
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Also known as an invalid solution unless they can explain it. :?

Never mind the fact that the simple and proper solution has already been posted, there's no need for some kind of an 'Alternate Solution Contest' here and no prize for the goofiest... sorry. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
dsx999
Participant
Posts: 29
Joined: Mon Aug 11, 2008 3:40 am

Post by dsx999 »

Some people are slowly changing the DSXchange to a "knowledge(?) expo" from a "knowledge base" with their over-excitement. In a recent post, I asked a very simple question and got only 2 solutions and around 10 other useless comments. Please think neotically before throwing some garbage.
It doesn't even help anybody's learning process also. Just shows the false-ego, earned with a little knowledge.

We have technology's best people here. So let us show some respect to them with sensible environment.

I know my comments are a bit rude. Sorry for that.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Abs() works - provided that the argument is numeric and not null.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply