4

Trying to make an if statement that will return 4 outcomes based on the contents of the cell

If the cell is "Yes", "No", "NA", "Unknown", to return 0, 1, 2, 3 respectively.

I can use If(A1="Yes", 0,1) but not sure how to handle the other conditions

3 Answers 3

6

SWITCH would be a better call:

=SWITCH(A1,"Yes",0,"No",1,"N/A",2,"Unknown",3,"I'-'I")
Sign up to request clarification or add additional context in comments.

Comments

2

Please try:

=IF(A1="Yes",0,IF(A1="No",1,IF(A1="Unknown",3,2)))

Anything other than the given selection in A1 (and not an error) and the formula would return 2.

Comments

1

The concept you are asking for in the Google Docs Editors help center is called "nested function". This concept refers to using a function as a parameter of another function.

The syntax for IF is

IF(logical_expression, value_if_true, value_if_false)

You could replace logical_expression, value_if_true and/or value_if_false with another IF. For this specific case, try

=IF(A1="Yes",0,IF(A1="No",1,IF(A1="NA",2,IF(A1="Unknown",3,NA())))

#N/A will be returned if A1 contains an unexpected value.

Reference

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.