1

I'm using Google Sheets and I have this issue: is there any way to save the logical condition in the IF function into a cell? For example, we have this function:

=IF(B1>0; "Positive"; "Negative")

Could I in some way save condition 'B1>0' into a cell A1 and use like so:

=IF(A1; "Positive"; "Negative")

Obviously I can't do it like that because A1 is not a bool value. Is there any way to convert it into bool or save that condition in any other way?

Thanks in advance

1 Answer 1

0

Put in A1

=B1>0

A1 will display true or false according to the value in B1, and then you will be able to write

=IF(A1; "Positive"; "Negative")

If you want to store only the condition, put in A1

=">0"

then write

=evaluate(B1&A1)

with a custom function

function evaluate( formula ) {
  if (formula.charAt(0) === '=') formula = formula.substring(1);
  return eval(formula)
}

since evaluate() doesn't exist in google sheets

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.