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

Three if Statement Formula

SOLVED
Highlighted
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
Highlighted

Re: Three if Statement Formula

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
Highlighted

Re: Three if Statement Formula

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

Highlighted

Re: Three if Statement Formula

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

Highlighted

Re: Three if Statement Formula

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

Oops! Good catch. I missed that

Highlighted

Re: Three if Statement Formula

Thanks for answering my question Richard!!!

Highlighted

Re: Three if Statement Formula

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

Highlighted

Re: Three if Statement Formula

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

Re: Three if Statement Formula

Thanks Leopold!!

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

Announcements