Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google sheets, if statement multiple conditions

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

like image 242
Bret Allan Avatar asked Dec 23 '22 12:12

Bret Allan


2 Answers

SWITCH would be a better call:

=SWITCH(A1,"Yes",0,"No",1,"N/A",2,"Unknown",3,"I'-'I")
like image 61
TheMaster Avatar answered Jan 16 '23 01:01

TheMaster


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.

like image 40
pnuts Avatar answered Jan 16 '23 01:01

pnuts