You are on page 1of 22

IF FUNCTION

Excel IF Function
MS Excel, or Microsoft Excel, is a powerful spreadsheet program that enables
users to record large amounts of data in cells within multiple worksheets.

Additionally, it allows users to perform various mathematical calculations and


analytical operations on recorded data using a wide range of existing

functions and formulas. The IF function is one such built-in widely used, most
popular Excel function.
What is the IF Function in Excel?
The Excel IF function performs a logical
comparison between two values (or cells containing
values). The function evaluates if the supplied
condition satisfies and then returns an output value
depending on whether the result of the condition is
TRUE or FALSE. In particular, the IF
function is an inbuilt conditional function that
returns a value based on the fulfillment or non-
fulfillment of the supplied condition.
For example, we can use the IF function to compare
two values, whether the value in cell A1 is greater
than that in cell B1. If the conditions
satisfy, it results as the TRUE; otherwise, FALSE.
The working of the Excel IF function is almost similar to the appropriately
structured Flow Chart. The function is mainly useful when making logical
interpretations for decision-making. We can also extend the logical test functionality
of the Excel IF function by combining it with other logical functions, such as AND,
OR, etc.
Syntax of IF Function
The syntax of the Excel IF function is defined as below:
1.=IF(logical_test, value_if_true, value_if_false)
Where, the 'logical_test', 'value_if_true', and 'value_if_false' are the three parts or
arguments in the IF function.
Based on the above syntax, the general format of the Excel IF function is defined as
below:
=IF(A1>B2, "TRUE", "FALSE")
We separated the different arguments (or parts) in the IF formula by a Comma (,).
However, we can also use the Semicolon (;) based on the language settings of the
machine/ device.
Arguments of IF Function
The IF Formula in Excel accepts the following three arguments:
ADVERTISEMENT
ADVERTISEMENT
•Logical_test: It is the first and the mandatory argument. It helps us specify the
condition to be tested or evaluated as either TRUE or FALSE. The specified condition
can be a value or a logical expression.
•Value_if_true: It is an optional argument accepted by the IF function. It helps us
specify the value that we need to return as output when the given condition (logical_test)
is 'TRUE'.
•Value_if_false: It is another optional argument accepted by the IF function. It helps us
specify the value that we need to return as output when the given condition (logical_test)
is 'FALSE'.
General Flow Chart Structure of Excel IF Function
As discussed above, the IF function works on the concept of a flow chart. Depending on the condition and usage of several
logical functions, the flow chart of the IF function may appear to range from simple to complex accordingly. We can draw a
flow chart of generic IF function like below:
The above flow chart shows that there is only one condition or
criteria, while the two outcomes are based on condition
satisfaction. If the condition is satisfied (evaluated as TRUE),
the function returns the value from the left box. If the condition
is not satisfied (evaluated as false), the function returns the
output from the other side.
Logical Operators used in IF function
The Excel IF formula typically uses logical operators to compare the values based on
the given condition. When evaluating a test using the IF function, we can use any of
the below logical operators:
How to use the IF Function in Excel?
To use the IF function in our Excel sheet, we must perform the following
steps:
• First, we must enter or type the equal sign (=) to start the function name.
• Next, we must type the function name, followed by the starting bracket,
i.e., =IF(.
• In the next step, we need to give the function the first argument (logical_test).
We must specify the condition using operators' signs for logical comparison.
• After that, we need to give optional arguments, returning a value as an output
based on the TRUE or FALSE.
Excel IF Function Examples
Let us understand the concept and working of the Excel IF Function better with
the help of the following examples:
Example 1: Basic IF Function application for empty/ non-empty cell
Everyone knows that life is not possible without oxygen. Suppose we have the
following excel sheet as an example data set where column A contains the list of some
planets and column B contains data about the availability of oxygen for these planets.
We only need to use the Excel IF function to find the planets where life is possible.
We can use the oxygen availability criteria in the IF function to get the desired result.
Let us now put the IF formula in our resulting column C (cells C2 to C5) and find
the names of the planets with the potential for life among the planets listed in our
example sheet:
• First, we find the possibility of life on the first planet (i.e., Jupiter). So, we select the
respective resultant cell C2 and start the formula by entering an equal sign. After that, we
enter the IF function name and the starting bracket, as shown below:
Lastly, we give values to be returned based on the satisfaction and dissatisfaction of
the condition. If the condition matches, we want the IF function to return: 'Life is
possible here'. If the condition does not match, we want the IF function to return:
'Life is not possible here'. We use the Comma (,) to separate the arguments. So, the
entire formula looks like this:
After finding the result for the first planet, we can apply the IF formula in the
remaining resultant cells accordingly. However, it will be easier to copy-paste the
formula from C2 to other cells below. Also, we can drag the formula using the
Fill Handle. This will help us perform the task quickly.
IF function based on equal to
The IF function based on equal to condition checks whether the given number is
equal to the specified value.

Example: Check whether the specified data is equal to some value.


The steps to be followed are:
Step 1: Enter the data in the worksheet, namely A1:C7
Step 2: To check whether the cost of each product is higher than 1000,
enter the Formula in the cell D2 as =IF (C2>1000, "Yes," "No")
Step 3: The Fill Handle option fills the Formula for the
remaining cells, which displays the required result.
IF function based on Lesser than
The IF function based on the lesser than condition checks whether the given number is lesser than the
specified value.
Example: Check whether the specified data is lesser than some value.
The steps to be followed are:
Step 1: Enter the data in the worksheet, namely A1:C7
Step 2: To check whether the cost of each product is lesser than 1000,
enter the Formula in the cell D2 as =IF (C2<1000, "Yes," "No")
IF Function using NOT function(<>)
The IF function and the function on(<>) are used to check
various criteria in the selected cell.
The steps to be followed are:
1. Enter the data in the cell range A1:A5
2. To check whether the cell range is not blank, enter the
Formula in cell B1 as =IF(A1<>",1,0). Press Enter.

The Function returns the value one


if the cell is not blank and returns
the value zero if the 3. cell is
blank.
4. Use the fill handle to display the
result for the remaining cells.

You might also like