Tuesday, November 5, 2019

How to use the Excel IF Function?

Brief Introduction

          IF Function is one of the most popular functions among the Decision-Making Functions. IF Function gives the desired intelligence to a program so that it can take decisions based on criteria and most importantly decide the program flow.
         According to Microsoft Excel, IF statement is defined as a function which “checks whether a condition is met, returns one value if True and another value if False”.

Purpose:
Test for a specific condition.

 Syntax of Excel IF Statement:
 The syntax of If Function in Excel is as follows;

=IF (Logical_Test, [Value_if_True], [Value_if_False])

Return value:
The values you supply for TRUE or FALSE.

 Arguments:
 Here, ‘Logic_Test’ refers to the expression that is to be evaluated.
‘Value_if_True’ is the output of IF Statement if the ‘Logic_Test’ is TRUE.
‘Value_if_False’ is the output of IF Statement if the ‘Logic_Test’ is FALSE.

Logical operators
When you are using a test with IF, you can use any of the following logical operators:

Comparison operator
Meaning
Example
=
equal to
A1=D1                                       .
> 
greater than
A1>D1
>=
greater & or equal to
A1>=D1
< 
less than
A1<d1
<=
less than & or equal to
A1<=D1
<> 
not equal to
A1<>D1

You can download free the Complete Practice of Concern Topic of Microsoft Excel File, Click on the below download icon, 


         This article explains in simple terms how to use IF Function. It takes a step-by-step approach, & following below contents we will touch in this post.
  1. IF Function explanation through various examples
  2. Nested IF     
               In simple words, IF function is an instruction that checks any condition.

1.  IF Function-Example 1.

             Now let’s learn IF Function through practical examples. In the below example the result & 
criteria for the result is shown.
               In the right side of the image showing the criteria that if a student takes 65 above marks in the exam he will be pass while the below or equal to 65 marks will be fail.
          In the left side of the image the selected cell D3 show that student by name Vejeh Sigh take 45 marks that according to the criteria is fail, as the IF Function shown the exact result in the cell D3. In this scenario, we have used a formula like below,

=IF(C3>=66,"Pass","Fail")

 Now according to the above formula, that first, we are comparing the number at C3 i.e. 45 (Score of Second Student) with our condition. This expression show (45 >= 65) i.e. Is 45 Greater than or equal to 65, which is not True, Hence the result will not be ‘Value_if_True’ While (second parameter of if statement) i.e. is “Fail” which meet by above selected cell.

IF Function-Example 2.   

         In the second example, the Employee salary table of a company is shown. We have to calculate the Allowance for these employees. As you can see in the below image the company has specific criteria for giving Allowance to its employees.

            The above in image criteria is, if the employee salary is greater than or equal to $ 9000 then allowance will be 20% of the salary otherwise, the Allowance will be 13% of the salary.
In this scenario, we can use the Excel if Statement as;

=IF(C3>=9000,C3*20%,C3*13%)
           
          In the above formula, first of all, we check if the salary of the Second employee (in C3 cell) is greater than or equal to 9000. If this is true then the formula evaluates an expression (C3 * 20%) otherwise, the result should be calculated by the expression (C3 * 13%).
As the salary of the second employee satisfies the condition i.e. (10,000 >= 9000). So, the result of this formula is (10,000 x 20%) which comes out to be $ 2,000.

IF Function-Example 3.

In the below example IF Function is used for currency exchange as we see in the image,
         
         Explanation: In the above example the selected cell "E3", We see that there is a condition applied if "B3" Cell contains the value "USD" then "C3" will be multiplied with "D3" else return is "zero", in the example it does not meet the condition because of "B3" Contain "EUR", So return is "Zero".  
In this scenario, we can use the Excel if Statement as;

=IF(B3="USD",D3*C3,D3*0)

In the other side when we are going to exchange currency from EUR to USD then see the below example,

The same row F3 Cell meets the condition & it exact calculate the Qasim Ali amount (200*1.117 = 223USD)

IF Function-Example 4.

     We can use the IF Function to display an empty string ("") if the end value hasn't been entered yet,


Explanation: if the end value is not empty (<> means not equal to), the IF function calculates the progress between the start and end value, else it displays an empty string ("").
In the above scenario, we use the Excel IF Function as;

=IF(B6<>"",B6-A6, "") 

So according to the above scenario we see that the last value in "B6" Cell is not entered yet, so as "D6" cell has shown empty.

2.  Nested IF Function.

            The IF function in Microsoft Excel can be nested, when you have multiple conditions to meet. The FALSE value is being replaced by another IF function to make a further test.
For example, take a look at the nested IF formula in cell D5 below.


       Explanation: if the grade equals "A", the nested IF formula returns "Excellent", if the grade equals "B", the nested IF formula returns "Good", if the grade equals "C", the nested IF formula returns "Fair", if the grade equals "D", the nested IF formula returns "Satisfactory", else it returns "Not Valid".
In this scenario, we can use the Excel IF Function as;

=IF(C5="A","Excellent",IF(C5="B","Good",IF(C5="C","Fair",IF(C5="D","Satisfactory","Not Valid")))) 

In the above selected cell we see that grade is equal to "B" so it returns is "Good" according to our criteria.


No comments:

Post a Comment