How to convert negative values to positive in adf

Anonymous
2022-06-09T08:39:37.92+00:00

I'm loading source files to stage table. By using data flow activity. I have few negative values in my xl file. So how to convert negative values to positive by using derived column transformation in Azure Data Factory.

Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
11,625 questions
0 comments No comments
{count} votes

Accepted answer
  1. AnnuKumari-MSFT 34,556 Reputation points Microsoft Employee Moderator
    2022-06-10T10:10:39.66+00:00

    Hi @Rohith-0358 ,
    Welcome to Microsoft Q&A platform and thanks for posting your query.

    As I understand your ask here, you want to convert negative int values to positive using ADF . As correctly mentioned by @Nandan Hegde and @Samy Abdul , you can use abs function in derived column transformation in the mapping data flow to achieve this requirement.

    To reproduce your scenario, I created a table having a column 'num' which contains negative records .

    210255-image.png

    Used Derived column transformation to make change in existing column using expression abs(toInteger(byName('num')))

    210228-image.png

    Here is the result,

    210242-image.png

    Hope this will help. Please let us know if any further queries.

    ------------------------------

    • Please don't forget to click on 130616-image.png or upvote 130671-image.png button whenever the information provided helps you.
      Original posters help the community find answers faster by identifying the correct answer. Here is how
    • Want a reminder to come back and check responses? Here is how to subscribe to a notification
    • If you are interested in joining the VM program and help shape the future of Q&A: Here is how you can be part of Q&A Volunteer Moderators
    0 comments No comments

2 additional answers

Sort by: Most helpful
  1. Nandan Hegde 36,146 Reputation points MVP Volunteer Moderator
    2022-06-09T08:41:01.977+00:00

  2. Samy Abdul 3,376 Reputation points
    2022-06-09T08:49:35.403+00:00

    Hi @Rohith-0358 , please use negate function:

    abs
    abs(<value1> : number) => number

    Absolute value of a number.

    abs(-20) -> 20
    abs(10) -> 10

    negate
    negate(<value1> : number) => number

    Negates a number. Turns positive numbers to negative and vice versa. Thanks

    negate(13) -> -13 Thanks


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.