The IF function is one of the most popular functions in Calc and other spreadsheet applications. IF performs a logical test and return one value for a TRUE result, and another for a FALSE result. In its simplest form, the IF function says:
IF(Something is True, then return value1, otherwise return value2)
Let's see a typical example of the IF function. A teacher uses a spreadsheet to calculate the average (final) score of his students.
In the Pass/Faill column he wants to display a "Pass" text if the final score is greater or equal to 70. Using the IF function the formula is
After the function is filled the "Pass" or "Fail" result will be displayed.
Then you can use autofill to fill the remaining cells.
Returns one of two values, depending on a test condition.
IF(test; value1; value2) where:
test is or refers to a logical value or expression that returns a logical value (TRUE or FALSE).
value1 is the value that is returned by the function if test yields TRUE.
value2 is the value that is returned by the function if test yields FALSE.
If value2 is omitted it is assumed to be FALSE; if value1 is also omitted it is assumed to be TRUE.
IF(A1>5; 100; "too small")
returns the number 100 if A1 is greater than 5, and the text "too small" otherwise.
returns FALSE - because value2 has been omitted and 1 is not greater than 2.
returns TRUE - because both value1 and value2 have been omitted and 2 is more than 1
Comparative operators are found in formulas that use the IF function and return either a true or false answer.
|=||Equal||A1 = B1|
|>||Greater than||A1 > B1|
|<||Less than||A1 < B1|
|>=||Greater or Equal than||A1 >= B1|
|<=||Less or Equal than||A1 <= B1|
|<>||Inequality||A1 <> B1|