Imagine you are a teacher checking the examination results of students in a secondary school in Lagos. To qualify for an award, a student must score at least 70 marks in Mathematics and English.
Checking every student's results manually can take a long time. Fortunately, Microsoft Excel has logical functions that can help you check conditions and make decisions automatically.
In this module, you will learn how to use AND, OR, and NOT functions to analyse information and make decisions in Excel.
By the end of this module, you should be able to:
Logical functions help Excel make decisions by checking whether something is true or false.
For example, imagine your school says that students must score 50 marks or more to pass an examination.
Excel uses logical results to help you analyse information and automate decisions.
The AND function checks two or more conditions. It returns TRUE only when all the conditions are true.
If even one condition is false, the AND function returns FALSE.
=AND(logical1, logical2, ...)
Each logical argument is a condition that Excel must check.
A school in Ibadan wants students to score at least 50 marks in both Mathematics and English to qualify for a special class.
| Student | Mathematics | English |
|---|---|---|
| Ade | 75 | 80 |
| Chika | 65 | 40 |
| Tunde | 45 | 70 |
| Fatima | 90 | 85 |
Assume Mathematics scores are in column B and English scores are in column C. Enter this formula in D2:
=AND(B2>=50,C2>=50)
The results will be:
| Student | Mathematics | English | AND Result |
|---|---|---|---|
| Ade | 75 | 80 | TRUE |
| Chika | 65 | 40 | FALSE |
| Tunde | 45 | 70 | FALSE |
| Fatima | 90 | 85 | TRUE |
Ade and Fatima meet both conditions. Chika and Tunde do not.
The OR function checks two or more conditions. It returns TRUE if at least one condition is true.
It returns FALSE only when all the conditions are false.
=OR(logical1, logical2, ...)
Imagine a school gives an award to students who score at least 90 in Mathematics or at least 90 in English.
Enter this formula in D2:
=OR(B2>=90,C2>=90)
| Student | Mathematics | English | OR Result |
|---|---|---|---|
| Ade | 75 | 80 | FALSE |
| Chika | 95 | 40 | TRUE |
| Tunde | 45 | 92 | TRUE |
| Fatima | 90 | 85 | TRUE |
Chika, Tunde, and Fatima qualify because each student scored at least 90 in one of the two subjects.
The NOT function changes TRUE to FALSE and FALSE to TRUE. It reverses a logical result.
Think of it as telling Excel to check the opposite of a condition.
=NOT(logical)
Assume a student passes when the score is 50 or more. The score is stored in cell B2.
Enter:
=NOT(B2>=50)
If the score is 75, the condition B2>=50 is TRUE, so NOT changes the result to FALSE.
If the score is 35, the condition is FALSE, so NOT changes the result to TRUE.
You can combine logical functions with IF to make Excel display words instead of only TRUE or FALSE.
For example, a school may decide that a student must score at least 50 in both Mathematics and English to pass both subjects.
Enter this formula:
=IF(AND(B2>=50,C2>=50),"Qualified","Not Qualified")
Excel first checks both conditions using AND. It then uses IF to display Qualified if both conditions are true, or Not Qualified if either condition is false.
You can also combine OR with IF when only one of several conditions needs to be true.
Imagine a company gives a transport allowance to employees who live in either Lagos or Ibadan.
Assume the employee's city is stored in cell B2. Enter:
=IF(OR(B2="Lagos",B2="Ibadan"),"Allowance Approved","Not Eligible")
If the employee lives in Lagos or Ibadan, Excel displays Allowance Approved. If the employee lives in another city, it displays Not Eligible.
Imagine a supermarket in Lagos wants to identify products that need restocking.
The manager decides that a product needs restocking if its quantity is below 10 units or its quantity is exactly 10 units.
| Product | Quantity Available |
|---|---|
| Rice | 25 |
| Milk | 5 |
| Soap | 10 |
| Bread | 8 |
Enter this formula in C2:
=IF(OR(B2<10,B2=10),"Restock","Stock Available")
The results will be:
| Product | Quantity | Decision |
|---|---|---|
| Rice | 25 | Stock Available |
| Milk | 5 | Restock |
| Soap | 10 | Restock |
| Bread | 8 | Restock |
| Function | What It Does | Example |
|---|---|---|
| AND | Returns TRUE when all conditions are true. | =AND(A2>=50,B2>=50) |
| OR | Returns TRUE when at least one condition is true. | =OR(A2>=50,B2>=50) |
| NOT | Reverses a TRUE or FALSE result. | =NOT(A2>=50) |
A secondary school in Ibadan wants to identify students who qualify for a special mathematics programme.
A student must score at least 60 in Mathematics and at least 50 in English to qualify.
| Student | Mathematics | English |
|---|---|---|
| David | 75 | 65 |
| Mary | 85 | 45 |
| John | 55 | 70 |
| Grace | 90 | 80 |
| Peter | 40 | 35 |
In this module, you learned about three important logical functions in Excel:
You also learned how to combine AND and OR with IF to make Excel display useful decisions automatically.
In Module 5, you will learn about Text Functions for Data Analysis. You will discover how to join names, extract parts of text, change letter cases, remove unwanted spaces, and clean information in Excel.