The IF function in Google Sheets is used to make decisions with your data. It’s from the Logical family of functions in Google Sheets. At its heart, the IF function is a test that evaluates to a true or false value with a defined behavior if the outcome is true and a different behavior when the outcome is false.
SYNTAX: =IF(logical_expression, value_if_true, balue_if_false)
logical_expression: An expression that gives a TRUE or FALSE answer
value_if_true: The value displayed by the IF function if the logical expression has the TRUE value
value_if_false: The value displayed by the IF function if the logical expression has the FALSE value.
The values in an IF function can be numerical or text. If you use text values, you need to wrap the expression in quotation marks.
The best way to look at this function is through a specific example. In the data below, in column C we want to state which column, A or B, has the higher value.
We will use the IF function below in column C:
=IF(A2>B2, "A", "B")
Lets break it down using the syntax state above:
logical_expression: A2>B2 -> this mathematical statement will be tested. It states A2 is larger than B2.
value_if_true: "A" -> If the mathematical statement is true (if the value in cell A2 is larger than B2) then the letter A will be put in cell C2.
value_if_false: "B" -> If the mathematical statement is false (if the value in cell A2 is smaller than B2) then the letter B will be put in cell C2.
The value_if_true and the value_if_false can be either:
Text: If, like in the example, the words/text are put in quotation marks.
Another Cell Value: You can name any other cell value (i.e. D2).
Use this link to see additional examples and uses for the IF function.