Hi Community,
This might be a super simple one but my maths is simply failing me big time.
Basically I have two values a negative value and a positive value and I need to subtract the negative value from the positive value, however when I subtract them the negative value is being added on to the Positive value and increasing it.
I have no idea how to fix this so any help would be terrific,
cheers everyone
Here is a a sample of the two values and the formula I have tried to use:
Formula: [Value 2]-[Value 1]
Code | CompanyName | Value 1 | Value 2 | Total | 2021 |
ABC021_C | Test Company Limited 1 | -750 | 2000 | 2750 | TRUE |
Solved! Go to Solution.
Reason: you're trying to subtract a negative number. Recall: x--y = x+y.
You could solve your issue by doing the following [Value2]-abs([Value1]).
This will make Value 1 positive. So rather than 2000 - (-750), it will be 2000 - (750)
Subtracting a negative number from X increases the value of X. Alteryx is calculating the formula correctly. You might want to add the numbers together instead?
@BS_THE_ANALYST WOW I'm genuinely embarrassed by my maths cheers for that the issue is fixed now
If you are always trying to find the 'total' between the two columns. Just add them together.
i.e.
val1: 4000 val2: 3000 total = 7000 -> 4000+3000
val1: 4000 val2: -3000 total = 1000 -> 4000+-3000
val1: -4000 val2: -3000 total = -7000 -> -4000+-3000
val1: -4000 val2: 3000 total = -1000 -> -4000 + 3000
All possibilities covered so you can rest assured adding the two columns will always return the total @Deano478
@BS_THE_ANALYST Much appreciated i never knew about the ABS function so I was sat here struggling so looks like I learned something new today
hey again @BS_THE_ANALYST just one more question for you I was working away using the ABS function and one of my calculations is:
Value1: 200
Value2: 8660
But when I try to subtract them using: [Value2]-ABS([Value1]) it does nothing in this case for some reason?
heres a snippet of the output:
@BS_THE_ANALYST Please ignore my last reply my apologies
Hi @Deano478 .. so to clarify what the 'ABS' function is doing. It takes any value, and makes it positive!
So if you do this -> ABS(-400) it will pop out 400 as the result
So if you do this -> ABS(400) it will pop out 400 as the result
I think you were expecting to see the number 9060 as your result here because you're trying to work out the TOTAL;
i.e.:
To work out the total, just do this [Value2]+[Value1].
Remember, the ABS function is just to make a number positive! I hope that makes sense? Adding negatives and subtracting negative numbers can be mind boggling!