Formula with absolute value?

itexet

New Member
Joined
Feb 5, 2018
Messages
6
x=...
y=...
5*(x-y)=
if "x" and "y" are with different signs (-/+ or +/-) the formula should be like that,
but if "x" and "y" are with same signs (-/- or +/+) in the brackets should stay only one value with his sign - the absolute value of (x and y).
How should it look like?
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
Welcome to the Board!

I am afraid I am not entirely clear what you are asking here:
but if "x" and "y" are with same signs (-/- or +/+) in the brackets should stay only one value with his sign - the absolute value of (x and y).
What don't you actually show us what you mean by giving us a few real examples, where you give us real values for x and y and show what should happen in each case?
 
Upvote 0
Welcome to the Board!

I am afraid I am not entirely clear what you are asking here:

What don't you actually show us what you mean by giving us a few real examples, where you give us real values for x and y and show what should happen in each case?

If we have different signs:
x=1
y=-2
The formula should look like this: 5*(1-(-2))

If we have similar signs:
x=-3
y=-6
The formula should look like this: 5*(0-(-6))
We take the absolute value.

One more example:
x=-3
y=-1
formula: 5*(-3-0)
 
Upvote 0
I think you are mixing up your mathematical terms.
Absolute value simply means if the number is negative, change it to positive. So the absolute value of -6 is 6.

It looks like you are are taking the maximum of a number and 0, i.e.
the maximum of -3 and 0 is 0
and the maximum of -1 and 0 is 0

So, are you always applying that maximum to the larger of the two values?
What if you had x=3 and y=6?
Then what should the formula look like?
 
Upvote 0
I mean the bigger number with his sign:
x=-2; y=-6 -> the bigger is -6

If x=3 and y=6 -> 5*(0-(+6))
 
Upvote 0
x=-2; y=-6 -> the bigger is -6
Mathematically speaking, -2 is bigger than -6.
Maybe this is where the absolute value comes in, when you mean the absolute value of -6 is greater than the absolute value of -2.

If x is in cell A1, and y is in cell B1, try this formula:
Code:
=IF(OR(AND(A1>0,B1<0),AND(A1<0,B1>0)),5*(A1-B1),IF(ABS(A1)>ABS(B1),5*A1,5*(-B1)))

However, you haven't said what should happen if one of the values is zero, or they are both the same.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,918
Messages
6,122,252
Members
449,075
Latest member
staticfluids

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top