Skip to main content
7-Bedrock
March 7, 2025
Solved

Unmatch results of “if” function

  • March 7, 2025
  • 2 replies
  • 1208 views

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!

Best answer by MZ_11733142

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

 

2 replies

21-Topaz II
March 7, 2025

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

7-Bedrock
March 7, 2025

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

MZ_11733142_0-1741358072634.png

 

21-Topaz II
March 7, 2025

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..

25-Diamond I
March 7, 2025

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.

 

21-Topaz II
March 7, 2025

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

 

25-Diamond I
March 7, 2025

@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" 😉