IF AND OR Not correct

honkin

Active Member
Joined
Mar 20, 2012
Messages
385
Office Version
  1. 2016
Platform
  1. MacOS
I have a formula to try and make a calculation of profit or loss, but cannot seem to get it to function correctly

C is the number of runners
R is the price
T is the finish position

Here is the formula
Code:
=IF(OR(AND(C2<=3,R2<=20,T2>1),-80, AND(C2>=4,C2<=7,R2<=20,T2>2),-80, AND(C2>=8,R2<=20,T2>3),-80),78.4*S2-78.4,0)

So what I am trying to achieve is the following:

IF C2<=3 & R2<=20 & T2=1 then perform the profit calculation. Otherwise the answer-80 (if R2 is >20 the answer should be 0)
or
IF C2>=4 & C2<=7 & R2<=20 & T2<=2 then perform the profit calculation. Otherwise the answer is -80 (if R2 is >20 the answer should be 0)
or
IF C2>=8 & R2<=20 & T2<=3 then perform the profit calculation. Otherwise the answer -80 (if R2 is >20 the answer should be 0)

So the R2<=20 seems to be the vital part, as if R2 >20, then the result will always be zero - no calculations necessary at all. If R2 is <=20, then the other criteria need to be used, with either a profit calculation or loss of -80 showing. Only 3 possibilities, 0, Profit or -80

There are obviously some flaws in this, but it is beyond me to figure it out.

Thanks in advance
 

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.
Just as a follow up, here is the same code as above without the price check in R2. Well, it is slightly different, as I moved the -80 around to try and accommodate the price check, but couldn't get it to work.This code works flawlessly, but just does not have the price check

Code:
=IF(OR(AND(C2<=3,T2=1), AND(C2>=4,C2<=7,T2<=2), AND(C2>=8,T2<=3)),78.4*S2-78.4,-80)

I just need this whole formula to also check that if R2 >=20, then the answer is always 0

Any help gladly accepted
 
Upvote 0
Like this?

=IF(R2>=20,0,IF(OR(AND(C2<=3,T2=1), AND(C2>=4,C2<=7,T2<=2), AND(C2>=8,T2<=3)),78.4*S2-78.4,-80))
 
Upvote 0
Like this?

=IF(R2>=20,0,IF(OR(AND(C2<=3,T2=1), AND(C2>=4,C2<=7,T2<=2), AND(C2>=8,T2<=3)),78.4*S2-78.4,-80))
Ah you're a legend mate. Yep, that seems to handle it perfectly. Now I need to learn from that in case I ever have something similar. I can see the structure of this, so it helps

cheers
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,289
Members
452,631
Latest member
a_potato

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