Functions AND and OR are 2 logic functions that help you to create sophisticate logical tests.
Presentation of the functions
These functions are use to enhance a logic test. Basically, with a logical test you compare 2 items only. But if you want to create a test with more items, you have to use one of these functions.
A condition AND returns TRUE if and only if all tests in parenthesis are true.
A condition OR returns TRUE if one (or more) tests of the function is true.
This is a function available only for Excel 2013 and up but is used is very limited. This function is useful for electronic projects.
With the OR function, one or more test have to be TRUE to return TRUE. But with the XOR function only one tests of the function must be true. If you have more than one test TRUE, the function will return FALSE
Have a look at this post if you want to learn more about it.
Convert TRUE/FALSE to 0/1
Whatever your test, single test or with the functions AND or OR, the test will return TRUE or FALSE
But, you can change that by multiply your test by 1 to return 1 if it's TRUE or 0 when it's FALSE
=8>1 => TRUE
=(8>1)*1 => 1
Examples with AND or OR functions
Let's take this customer file. You want to extract some customers in function of criteria for your business.
Let's consider these different cases.
- How many clients are married with one child
- How many clients are single or divorced
- How many clients are married with an income above 75,000
- How many clients are male, unmarried and without children
- How many clients are women with 1 or 2 children.
- How many clients are married or in relationship, with an income greater than or equal to 50,000 and have at least two children.
- The answer for the question 1 is
- The answer for the question 2 is
- The answer for the question 3 is
- The answer for the question 4 is
- The answer for the question 5 is
- The answer for the question 6 is
Include a test in a IF function
All the previous tests are very useful but return TRUE or FALSE (or 1 or 0) but if you want to customize your result, like "Win" or "Lost", you must include these tests in the function IF.