Returns one value if a logical expression is `TRUE` and another if it is `FALSE`. Learn more
In Google Sheets, the IF function is a logical function that checks whether a given logical expression is true or false, and returns one value if it's true and another value if it's false.
The syntax for the IF function is:
IF(logicalexpression, valueiftrue, valueif_false)
logical_expression: This is the condition that you want to test. It can be a comparison of two values using operators like <, >, =, <=, >=, or it can be a logical expression like AND, OR, or NOT.
valueiftrue: This is the value that is returned if the logical_expression is true.
valueiffalse: This is the value that is returned if the logical_expression is false.
For example, suppose you have a cell A1 that contains a number, and you want to check whether it's greater than 10. If it is, you want to display the text "Greater than 10", otherwise you want to display the text "Less than or equal to 10". You can use the IF function to achieve this as follows:
=IF(A1>10, "Greater than 10", "Less than or equal to 10")