Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hi,
I want to change the amount value from positive to negative or negative to positive based on a condition as below.
Reference Data
Code | Amount |
A1 | 100 |
B2 | -80 |
C3 | 110 |
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.
Code | Value | New Value |
A1 | 100 | -100 (Became Negative from Positive) |
B2 | -80 | 80 (Became Positive from Negative) |
C3 | 110 | 110 |
Can anyone please help that how to achieve this?
Regards,
Solved! Go to Solution.
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])
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]))
Proud to be a Super User!
Paul on Linkedin.
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])
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]))
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
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
105 | |
96 | |
75 | |
63 | |
62 |
User | Count |
---|---|
135 | |
105 | |
104 | |
80 | |
65 |