cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - If community subscription notifications are filling up your inbox you can set up a daily digest and get all your notifications in a single email. X

Three if Statement Formula

jlee-5
1-Newbie

Three if Statement Formula

Hi All,

I'm a newbie with Mathcad and I'm self taught so I hope this is an easy on for you guys!!

I'm trying to get my head round why this formula doesn't work so any help would be great.

See the attached Mathcad 15 file.

I'm using if statements to pick the correct answer but I can't get it to completely work. At one point I thought I had it but then when you test it there's always one way it fails. grrrrrrrrrrr

Best Regards

Jonno

1 ACCEPTED SOLUTION

Accepted Solutions
lturek
4-Participant
(To:jlee-5)

Andy has already stated the problem with your (and Alans) routine.

The expression

yield1.png

will always simplify to TRUE and so despite  the returns also Alans approach would yield AllowYield everytime, disregarding the value of Yield.

Here is an alternative approach which I guess does what you had in mind.

yield2.png

You might consider turning the routine into a function to be more versatile.

View solution in original post

7 REPLIES 7
RichardJ
19-Tanzanite
(To:jlee-5)

Use the return statement to force the program to exit. Without that, as you note, it will always drop through to he next line.

AndyWesterman
4-Participant
(To:jlee-5)

alternate suggestion.

1. the Boolean operators take 2 logical inputs so where you write IF yield = 60 OR 75, Mathcad checks if yield =60 is true; or if 75 is true. any non zero number is true so therefore 75 = true

This needs to be written IF yield=60 OR yield =75

2 you need to consider the logic of the next statement : IF yield NOT= 60 OR yield NOT=75

one of the statements must be true so this will always be true.

it needs to change to: IF yield NOT= 60 AND yield NOT=75.

Hope this helps

Andy

This needs to be written IF yield=60 OR yield =75

Oops! Good catch. I missed that

Thanks for answering my question Richard!!!

Thanks for your reply! This works so i would of given it a correct answer but it wont let me put two correct answers down

lturek
4-Participant
(To:jlee-5)

Andy has already stated the problem with your (and Alans) routine.

The expression

yield1.png

will always simplify to TRUE and so despite  the returns also Alans approach would yield AllowYield everytime, disregarding the value of Yield.

Here is an alternative approach which I guess does what you had in mind.

yield2.png

You might consider turning the routine into a function to be more versatile.

jlee-5
1-Newbie
(To:lturek)

Thanks Leopold!!

This works great and you have shortened my formula!!!

Top Tags