Formula for Value Return Based on Positive and Negative Values

David Roberts

New Member
Joined
Jan 11, 2021
Messages
5
Office Version
  1. 365
Platform
  1. Windows
I'm trying to work out a formula that give me the correct return in 'E' based on the difference between 'C' and 'D'

Capture.PNG


I'm trying =SUM(ABS(C2:D2)) This seems to work for answers £51.00 (E2) and £50.00 (E3), but I can't get E4 to equal £49.00

Regards
Dave
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Welcome to the Board!

If the values currently shown in column D are what you want to see, there is no need to use the ABS function. Just use the simple formula:
Excel Formula:
=D2-C2

If that does not give you what you want, please explain in more detail what the correct results need to look like.
 
Upvote 0
Solution
Hi Joe

I can't believe it was that easy! I've done nothing more than over complicate the return.
I'm off to sit in a darkroom with a bucket load of coffee.
Many thanks
 
Upvote 0
Just when I thought my issue was straight forward the problem has bit me!

The issue I have come across now is the following:

Capture.PNG


The difference between the Customer Price and Sage price gives the correct return in 'C'. The transport cost is then added thus giving the return in 'E' in this case £33.52 which is correct.

However

The difference between Customer Price and Sage Price (A3-B3) gives C3 which is correct. By then including the transport cost of £50 (D3) then E3 needs to return an answer of Zero.

So, where the Customer Price is greater than the Sage Price the difference is added to the transport cost thus giving a low amount.

Where the Sage Price is Greater than the Customer Price, then the difference should be subtracted from the transport cost. So the example above in E3 should be £0

How do I formulate to include all possibilities?
 
Upvote 0
Try this formula in E2:
Excel Formula:
=IF(A2>B2,D2+C2,D2-C2)
 
Upvote 0
Thanks for coming back to me.
What happens if A2<B2? How do you combine the option of A2>B2 and also A2<B2 into one formula?
 
Upvote 0
Thanks for coming back to me.
What happens if A2<B2? How do you combine the option of A2>B2 and also A2<B2 into one formula?
It is already accounted for. It is already "baked into the formula".
The key is understanding how the IF formula works.
The structure of it is this:
=IF(condition,what to do if condition is TRUE,what to do if condition is FALSE)

So here are the three arguments:
condition: A2>B2
what to do if condition is TRUE: D2+C2
what to do if condition is FALSE: D2-C2

If the condition is false, then really what that is checking is A2<=B2
And in that case, it will do D2-C2

So, essentially what that formula is doing is:
If A2>B2, then do D2+C2
If A2<=B2, then do D2-C2

which, from my understanding of your question, is what you are looking for.

Try it out and see for yourself!
 
Upvote 0
Joe

Many thanks for the explanation, I fully understand the workings now.

Regards
Dave
 
Upvote 0
You are welcome.
Glad I was able to help!
:)
 
Upvote 0

Forum statistics

Threads
1,214,920
Messages
6,122,279
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