Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
AkshayManke
Helper II
Helper II

Negative to Positive or Positive to Negative

Hi,

 

I want to change the amount value from positive to negative or negative to positive based on a condition as below.

 

Reference Data

CodeAmount

A1

100
B2-80
C3110

 

Condition = If the Code is starting with A or B then change the Amount as (If '- then +' or If '+ then -' ). New Value will be captured in a different column.

 

So the outcome would be captured as below.

CodeValueNew Value
A1100-100 (Became Negative from Positive)
B2-8080 (Became Positive from Negative)
C3110110

 

Can anyone please help that how to achieve this?

 

Regards,

1 ACCEPTED SOLUTION
PaulDBrown
Community Champion
Community Champion

@AkshayManke 

If you want to add a new column:

Change sign (c) = 
VAR _Code = LEFT(Table1[Code], 1)
RETURN
SWITCH(TRUE(),
_Code = "A", Table1[Amount] * -1,
_Code = "B", Table1[Amount] * -1,
Table1[Amount])

Column.JPG

 

If you want it as a measure:

Change sign = 
VAR _Code = LEFT(SELECTEDVALUE(Table1[Code]), 1)
RETURN
SWITCH(TRUE(),
_Code = "A", SELECTEDVALUE(Table1[Amount]) * -1,
_Code = "B", SELECTEDVALUE(Table1[Amount]) * -1,
SELECTEDVALUE(Table1[Amount]))

Measure.JPG

 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






View solution in original post

2 REPLIES 2
PaulDBrown
Community Champion
Community Champion

@AkshayManke 

If you want to add a new column:

Change sign (c) = 
VAR _Code = LEFT(Table1[Code], 1)
RETURN
SWITCH(TRUE(),
_Code = "A", Table1[Amount] * -1,
_Code = "B", Table1[Amount] * -1,
Table1[Amount])

Column.JPG

 

If you want it as a measure:

Change sign = 
VAR _Code = LEFT(SELECTEDVALUE(Table1[Code]), 1)
RETURN
SWITCH(TRUE(),
_Code = "A", SELECTEDVALUE(Table1[Amount]) * -1,
_Code = "B", SELECTEDVALUE(Table1[Amount]) * -1,
SELECTEDVALUE(Table1[Amount]))

Measure.JPG

 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






Hello @PaulDBrown,

 

Thanks a ton for your help. The given dax is working exactly as expected. I have tried the column DAX and will try the measure as well.

 

Many thanks again!!

 

Regards,

Akshay

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

Find out what's new and trending in the Fabric community.