Excel's IF function runs a logical comparison and outputs a result as either TRUE or FALSE. For the example below, students who have secured a score of 50 or above will receive "PASS" or will receive "FAIL". The formula for this would be: =IF(C5>=70,"PASS","FAIL"). This is a very basic demonstration of the IF function. A complex formula may test more than one condition by nesting IF functions. The IF function can also be combined with other logical functions like AND and OR to extend the logical test. The result from the IF function can be a value, a cell reference, or even another formula. Syntax =IF(logical_test,[value_if_true],[value_if_false]) Arguments logical_test - A value or logical expression that can be evaluated as TRUE or FALSE. value_if_true - [optional] The value to return when logical_test evaluates to TRUE. value_if_false - [optional] The value to return when logical_test evaluates to FALSE. Users must understand the following to avoid confusion while using the IF function: The first argument of IF functions is a logical_test. It is generally an expression that returns a TRUE or FALSE as output. The second argument is value_if_true, the value to return when logical_test is TRUE. The last argument is value_if_false, the value to return when logical_test is FALSE. Both value_if_true and value_if_false are optional, but you must provide one or the other. For example, if cell A1 contains 60, then: =IF(A1>50,TRUE) // returns TRUE =IF(A1>50,"OK") // returns "OK" =IF(A155,"Yes","No") // returns "Yes" =IF(A1>85,"Yes","No") // returns "No" Users must enclose any text values in a formula with double quotes (''") like "Yes", "OK", "Red", "Green", etc. But, numeric values or cell reference does not need to be enclosed in quotes. Logical tests The IF function uses logical operators such as ">, <, , =" when creating logical comparisons. Most commonly, the logical_test in IF is a complete logical expression that will evaluate to TRUE or FALSE. The table below shows some common examples: GoalLogical testIf A1 is greater than 85A1>85If A1 equals 90A1=90If A1 is less than or equal to 100A1<=100If A1 equals "Green"A1="Green"If A1 is not equal to "Orange"A1"Orange"If A1 is less than B1A1<B1If A1 is emptyA1=""If A1 is not emptyA1""If A1 is less than current dateA1=50,"PASS","FAIL") Interpretation: If the value in C5 is greater than or equal to 50, assign "PASS". Otherwise, assign "FAIL". Note that the logical flow of this formula can be reversed and the formula returns the same result: =IF(C5<50,"FAIL","PASS") Interpretation: If the value in C5 is less than 50, assign "FAIL". Otherwise, assign "PASS". Both formulas above, when copied down, will return correct results. Example 2: Assign points based on color Consider a situation where we want to assign points based on the color names in column B. If the color is "Green", the result should be 150. If the color is "Yellow", the result should be 115. To achieve this, we need to use a formula with two IF functions, one NESTED inside the other. The formula is: =IF(B5="Green",150,IF(B5="Yellow",115)) Interpretation: IF the value in B5 is "Green", the result is 150. Else, if the value in B5 is "Yellow", the result is 115. There are three things to be noted down from this example: The formula will give the result "FALSE" if the value in B5 is anything except "Green" or "Yellow" The values, "Green" and "Yellow", must be enclosed in double quotes ("") because they are text. The IF function is not case-sensitive and will match "Green", "GREEN", "GeeN", or "gREEN". Example 3: Return another formula The IF function can also return another formula as a result. For example, the formula below will return A1*15% when A1 is less than 200, and A1*10% when A1 is greater than or equal to 100: =IF(A1<200,A1*15%,A1*10%) Example 4: Nested IF statements The IF function can also be nested. A "nested IF" refers to a formula where at least one IF function is nested inside another in order to compare more conditions and return more possible results. Each IF statement needs to be carefully "nested" inside another so that the logic is correct. For example, the following formula can be used to assign a letter grade: =IF(C6<50,"F",IF(C6<60,"D",IF(C6<70,"C",IF(C6