17/10/2024
AND and OR Logical Functions in Excel
Last week, I posted about logical functions in Microsoft Excel. One of the is the IF function, which has also been discussed. Today, in this post, I will be talking about the AND and OR Logical functions in .
They are logical functions that return either TRUE or FALSE based on the conditions provided. Let me talk about them a little.
AND Function: The AND function checks multiple conditions and returns TRUE . If any condition is false, it returns FALSE. The syntax for writing AND function is =AND(logical1, [logical2], ...)
Logical1, Logical2 are conditions you want to test (comparisons between values or cells). In Excel, one can create up to 255 conditions.
: =AND(B3=”Pregnant”,C3=”Male Child”)
This formula says, “if cell B3 contains the word “Pregnant”, and also cell C3 contains the word “Male Child”, Return/Produce/Display TRUE, then if anyone is not what is stated here, Return/Produce/Display FALSE ”
OR Function: The OR function is presented the same way as the AND function. The only difference is that in the AND function, all conditions must be met but in the OR function, only one condition is required. In other words, the OR function checks multiple conditions and returns TRUE if any of the conditions are true. If all conditions are false, it returns FALSE.
: =OR(C3=”Male Child”,D3=”Female Child”)
The formula above says, “return TRUE if any of the cells contains a MALE CHILD or a FEMALE CHILD
Both the AND and the OR functions are useful in decision-making formulas, especially when combined with IF for more complex logic. For example:
The two functions can be combined with the IF function to make better decisions in data handling.
:
=IF(AND(B5="Pregnant",C5="Male Child"),"Buy Car","Buy House")
Looking at the table in the picture below, the formula says, “If Ukamaka is Pregnant and it is a Male child, buy a car, if not, buy a house”
OR
“If cell B5 contains PREGNANT, and C5 contains MALE CHILD, return, BUY CAR if not, return BUY HOUSE”
If you understand these explanations, then interpret the formula below
=IF(OR(C6="Male Child",D6="Female Child"),"Buy House","nothing")
゚