Excel IF Function Examples
Excel IF statement is one of the most commonly used function in Excel. The Excel IF function allows you to perform logical comparisons between one value and the expected value.
The IF statement gives intended intelligence to a program to enable it take some form of decision. The decision that a given program will perform, depends upon criteria and program flow.
The Excel IF Function, comes in handy when evaluating mathematical or logical expressions. Therefore The Excel IF function is a function that checks if a condition is met and returns one value when True and another value when False. Simply put the function says: IF (Something is True, then do this, otherwise do that).
Excel IF Function syntax
The IF statement syntax is written as: IF (Logic_Test, Value_if_True, Value_if_False).
Logic_Test is the expression to be evaluated.
The Value_if_True refers to the output of the IF statement whenever the Logic_Test is TRUE.
And the Value_if_False statement is the output when the Logic_Test is False.
IF function always returns one value and never both at the same time.
The Excel IF Function can be nested, however, Excel only allows up to 64 Levels of Nesting. In situations whereby you are evaluating an invalid expression, the IF Function will return #Name? error. Whenever you are using a formula in the function, make sure you wrap the text in quotes. But since Excel automatically understands TRUE or FALSE you can exempt them from wrapping.
Excel IF Function with logical operators
Excel IF Function can be used alongside logical operators such as AND and OR. The application of both operators happens during analysis of complex logics. The operator AND only results into True once all the inside conditions are met.
The OR operator on the other hand will return True when one of the conditions is met. The syntax of these logics in Excel are written as: =AND (Logic1, Logic2, Logic_n) for AND logic. That of OR logic is written: =OR (Logic 1, Logic 2, Logic N).
For example, IF (AND (C2>=5, D2>=12000), D2*20%, “No Bonus”). In this case, in AND function two conditions have been used. They are, if C2 is greater than or equal to 5 and if D2 is greater than or equal to 12000. Once both conditions are True then only AND output will be TRUE. When any one of the value is FALSE the AND Function returns FALSE.
Using IF function to check if a cell is blank
It is important to always check if a cell is empty. This is important because it stops your formula from displaying results without input. The function that is normally used is the IF function with the ISBLANK statement. This is written as: =IF (ISBLANK (D2), Blank, Not Blank).
This translates into IF cell D2 is blank, then return Blank otherwise Not Blank. Also you may use your own formula for the Not Blank statement.
In as much as the Excel IF Function in Excel can be nested up to 64 IF different functions, it is advisable to avoid such nesting. This is a precaution to avoid inaccurately nested conditions that will return unexpected results.
Also multi-nested functions can be very difficult to maintain if you return to use them. At this point you may have forgotten what you meant or what someone was trying to do.