Forum Discussion

abukapsoun's avatar
abukapsoun
Post Patron
5 years ago
Solved

Multiplying values

Hi,

Need your support please.

I have the following Table

 

ReferenceP01P02
X-1000500
Y800-600
   
   

 

 

How can i transform the sign of values based on the following condition:

If Reference is X, then - make it + and the + make -

If reference is Y, then keep it as is

 

Many thanks in advance,

 

Regards,

 

 

  • Hi abukapsoun 

     

    There are 2 ways to do this.

     

    1. You can unpivot the columns, then create the new column with the IF function in DAX
    2. Or, you can create the IF function in Power Query Editor before unpivoting: Power Query > Add Column > Custom Column > Formula: if [Reference] = "X" then [P01]*-1 else [P01]

     

     

    **Update: formula amended as needed

9 Replies

  • Hi abukapsoun 

     

    You can create a new column with IF function.

     

    P01-New = IF('Table'[Reference] = "X", 'Table'[P01]*-1,'Table'[P01])

    P02-New = IF('Table'[Reference] = "X", 'Table'[P02]*-1,'Table'[P02])

    • abukapsoun's avatar
      abukapsoun
      Post Patron

      Thank you very much, will give it a try.

      Will I be able to unpivot the columns P01- New and P02 New ?

       

      • darentengmfs's avatar
        darentengmfs
        Post Prodigy

        abukapsoun 

         

        If this is a query, you can always unpivot it in Power Query mode.

         

        Power Query > Transform > Unpivot Columns

  • Seenu80's avatar
    Seenu80
    Regular Visitor

    Hi Experts,

    need your support on below i have absolute value in one column

    Shkg  Value

    H        100.00

    S           50.00

     

    if H, i need to do 100.00*-1 if S then 50.00. can you suggest how can i add new column based on above condition.

     

    Regards

    Srini