If you clearly understand the logical functions in Excel, they can prove to be very helpful in the long run. Through this article learn to use the 3 main logical functions:
- IF function
- AND function
- Combining IF and AND function
The IF function evaluates a particular condition in Excel. It returns one value if the condition is true and another value, if the condition is False.
Syntax of IF function
IF(logical_test, [value_if_true], [value_if_false]) wherein
• logical_test: Any value or expression that can be evaluated to TRUE or FALSE.
• value_if_true: The value that you want to be returned if the logical_test argument evaluates to TRUE.
• value_if_false: The value that you want to be returned if the logical_test argument evaluates to FALSE.
Using IF function
In the example below, we want to know if a student has passed a particular subject, so we shall use the IF function. Since the passing marks is 35 and above our logical_test is B2>=35 and our values are True and False. Make sure you insert your commas properly in order to avoid errors.
When you press enter and drag the fill handle, you shall get your desired results.
AND function is used when you want to check more than 1 condition. The AND Function returns TRUE if all conditions are true and returns FALSE if any of the conditions are false.
Syntax of AND function
AND(logical1, [logical2], …) wherein
• logical1: The first condition that you want to test that can evaluate to either TRUE or FALSE.
• logical2, … : Additional conditions that you want to test that can evaluate to either TRUE or FALSE, up to a maximum of 255 conditions.
Using AND function
In the example below, we want to know if the student has passed in both the subjects or no so we shall find this out by using AND function. Again the passing marks is 35 so our logical1 is B2>=35 and logical2 is C2>=35.
When you press enter and drag the fill handle, you shall receive your results as True and False wherein True means Pass and False means Fail.
What if you want Pass and Fail instead of True and False??? Well that is where our 3rd function comes in, that is using IF function with AND function. In the same example as above, we shall combine the IF and AND function. Refer the image below and you shall see that we have started off with an IF statement and then incorporated the AND function in it. Using your brackets and commas properly is a must over here.
When you press enter and drag the fill handle, you will notice that the data has been filled as Pass and Fail instead of True and False.
We hope that this article was useful to you. If you have any doubts or suggestions then mention it in our comments box and we shall get back to you as early as possible.