google sheets if and code example

Example 1: google sheets if

# Basic syntax:
=IF(condition, outcome_if_true, outcome_if_false)

# Note, the default setup for IF in Google Sheets is an IF ELSE

# Example usage:
=IF(A1 = "this text", "Houston, we have a match", 0)
# This returns "Houston, we have a match" if cell A1 is "this text", 
#	otherwise, it returns the number 0

Example 2: google sheets and

# Basic syntax:
=AND(condition_1, condition_2, condition_3, ...)
# Where AND() returns TRUE if all conditions are true, otherwise returns
#	FALSE
# Note, AND requires all conditions to return TRUE/FALSE or a number to
#	work. In general, 0 is treated as a FALSE and all other numbers are
#	treated as TRUE

# Example usage:
AND(A2 = "foo", A3 >= 7, isdate(A4))
# This returns TRUE if cell A2 is "foo", cell A3 is greater or equal to
#	7, and cell A4 is a date

Tags:

Misc Example