Home
» Wiki
»
IF and IFS functions in Excel: Usage and specific examples
IF and IFS functions in Excel: Usage and specific examples
Video IF and IFS functions in Excel: Usage and specific examples
The IF and IFS functions in Microsoft Excel are two of the logical functions used quite commonly for Microsoft Office users . In simplest terms, the IF / IFS function will return results based on one or several input comparison data.
Note :For examples and syntaxes of the IF and IFS functions below, we use a semicolon ( ; ) to separate, if in case the function reports an error or no output, please replace the semicolon ( ; ) with a comma ( , ).
IF function in Excel
With the IF function in Excel, you can perform a lot of different calculations including conditional formatting. For example, you can use it as an IF to classify students based on GPA, use the IF function to calculate numbers ...
An IF statement will return two results including the first one if the condition is TRUE, and the second one will be executed for the remaining conditions (FALSE).
IF function syntax
= IF ( Condition ; Do something if condition is true ; Do something with the other case )
If the above formula makes you confusing, please refer to the usage and the IF function examples in the content below.
Some examples in using the IF function
The IF function compares text (example): in the example below, cell D2 says: IF (C2 = Yes , then return 1 , otherwise return 2)
The IF function compares numbers: for example, in cell D2 says: IF (C2 = 1 , then returns Yes , otherwise returns No )
The IF function is larger than:
The formula in cell D2 will be: = IF (C2> B2; "Over Budget"; "In Budget")
The IF function returns the result of a mathematical calculation:
The formula in cell D2 will be: = IF (C2> B2; C2-B2; 0)
Use the IF function to check if a cell is blank
Sometimes you need to check if a cell is empty or not, usually because you don't want a formula to display the result without input. In this case, we will use the IF function together with the ISBLANK function :
The formula in cell D2 will be: = IF (ISBLANK (D2); "Blank"; "Not Blank")
In the next example, we will use "" instead of the ISBLANK function. The "" sign essentially means "nothing".
The formula in cell E2 is = IF (D3 = ""; "Blank"; "Not Blank")
In addition, the following is an example of a common method using "" to prevent a formula from performing calculations if an independent cell is empty:
= IF (D3 = ""; ""; Formula)
Explanation : IF (D3 has nothing, it returns no results, otherwise calculates your formula).
IF function nested to combine multiple conditions
While the simple IF function only has two results ( True or False ), the nested IF function can have 3 to 64 results.
= IF (D2 = 1; "YES"; IF (D2 = 2; "No"; "Maybe")
Explain the formula in cell E2: IF (D2 = 1 then return "Yes", otherwise IF (D2 = 2 then return "No", otherwise return "Perhaps") . Note that there are two closing parentheses at the end of the formula to complete both IF functions. If you try to enter a formula without both parentheses, Excel automatically adds the last closing parenthesis for you.
IFS function in Excel
If the IF function alone is enough to use the basic conditions, IFS will make you feel better because IFS will combine multiple IF functions in a single IFS. In other words, instead of using multiple nested IFs, you only need to use IFS.
IFS function syntax
= IFS ( Condition 1 ; Value if DK1 is correct ; Condition 2 ; Value if DK2 is correct ; Condition 3 ; Value if DK3 is true ; .............)
The IFS function can test up to 127 different conditions, but you should not nest too many conditions because it will be difficult to check if errors or data conflicts occur.
Example using IFS function
The formula for the cells in column B is: = IFS (A2> 89; "A"; A2> 79; "B"; A2> 69; "C"; A2> 59; "D"; TRUE; "F" )