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

Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X

Translate the entire conversation x

Unmatch results of “if” function

MZ_11733142
7-Bedrock

Unmatch results of “if” function

Dear all,

I'm encountering an issue with my sheets. The expression in the red box is producing incorrect results based on the Δna criteria.

 

984fb3f9-42e1-4af5-a26e-72a52c84e1aa.jpeg

 

Could anyone help with this?

Thanks!

ACCEPTED SOLUTION

Accepted Solutions

Thanks for the solution, i try to delete the "for" and use the "else if" and got the correct answer

MZ_11733142_0-1741368367586.png

 

View solution in original post

8 REPLIES 8

In the equalities one side has m as unit other just has 0.  Set the value to 0 m. for matching units in equalities.

Capture.JPG

hi, thanks for reply, but the results got the same wrong answer

MZ_11733142_0-1741358072634.png

 

Hi,

You need to use the if statements from the Math | Operators and Symbols | Programming | If statement .

Typing in the if statement does not work..

Werner_E
25-Diamond I
(To:MZ_11733142)

Can you post the sheet?

Maybe all you need to do is to omit the for-loop in your program. You seem to already have defined a range variable "i" in the worksheet.

BTW, is there any specific reason why you used "also if" instead of "else if" ?

I guess you should use "else if".

See the help for the difference between the two -> Conditional Operators

 

See if the attached example is of help.

 

knock me down with a feather you can use printed if statement in programming but you need to assign the result to something.

 


@terryhendicott wrote:

knock me down with a feather you can use printed if statement in programming but you need to assign the result to something.

 


Yes, but not necessarily in the "program" itself. Here your example without the assignment to the local variable c

Werner_E_1-1741363401885.png

The if-function is the last command executed in the program and so its result is the return value of the program.

 

In case of the expression in question the result of the if-functions used inside the programmed if-statement is assigned to the vector element sigmaip[i on the left hand side. Obviously he already defined a range variable "i" in the worksheet.

See the example in the file I attached in my last answer.

Werner_E_0-1741362582222.png

We could also use if-functions throughout, but I would strongly advise against doing so - especially given the much longer expression in the users work

Werner_E_0-1741363127648.png

 

All the user has to do is to delete the loop (which causes all the trouble) and replace the "also if" by an "else if" 😉

Thanks for the solution, i try to delete the "for" and use the "else if" and got the correct answer

MZ_11733142_0-1741368367586.png

 

Werner_E
25-Diamond I
(To:MZ_11733142)

Glad to see that it worked out for you.

 

Announcements

Top Tags