display value if google sheets code example

Example 1: google shets if

IF(A2 = "foo","A2 is foo")

IF(A2,"A2 was true","A2 was false")

IF(TRUE,4,5)

Example 2: 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