In the event you’ve ever needed to examine whether or not knowledge out of your Google Sheets spreadsheet meets sure standards, you should use AND and OR. These logical features provide you with TRUE and FALSE responses, which you should use to type by your knowledge.
In the event you use AND with a number of arguments, all of these arguments have to be true to get a TRUE response; in any other case, AND responds with FALSE. In the event you use OR, just one argument needs to be true for OR to offer a TRUE response.
You should use AND and OR individually or inside different features, like IF.
Utilizing the AND Perform
You should use the AND operate by itself or mixed with different features to offer a logical (TRUE or FALSE) take a look at.
To get began, open a Google Sheets spreadsheet and click on an empty cell. Kind
=AND(Argument A, Argument B) and change every argument with the factors you wish to use. You should use as many arguments as you’d like, however you could have at the least one for AND to work.
Within the instance under, we used three arguments. The primary argument is the straightforward calculation of 1+1=2.
The second argues that the cell E3 equals the quantity 17.
Lastly, the third argues that the worth of cell F3 (which is 3) is the same as the calculation of 4-1.
As all three arguments are true, the AND system responds with TRUE in cell A2. If we alter any of those arguments, it’s going to trigger the AND system in A2 to vary the response from TRUE to FALSE.
Within the instance under, the AND system in cell A3 has two appropriate arguments and one which’s incorrect (F3=10, whereas F3 truly equals 3). This causes AND to reply with FALSE.
Utilizing the OR Perform
Whereas AND requires all of the arguments it makes use of to be true, the OR operate solely requires one to be true for OR to reply with TRUE.
Like AND, you should use the OR operate by itself or mix it with different features. The identical as with AND, you should use as many arguments as you need, however you could have at the least one for it to work.
To make use of OR, click on an empty cell and sort
=OR(Argument A, Argument B), and change the arguments with your individual.
Within the instance under, the system utilizing OR in cell A2 has one incorrect argument out of three (F3=10, the place F3 truly equals 3).
Not like whenever you use AND, one incorrect argument out of three will end in a TRUE consequence. For a FALSE consequence, all of the arguments you utilize have to be incorrect.
Within the instance under, the OR formulation in cells A4 and A5 returned a FALSE response as a result of all three arguments in each formulation are incorrect.
Utilizing AND and OR with IF
As a result of AND and OR are logical features with TRUE and FALSE responses, you too can use them with IF. If you use IF, if an argument is TRUE, it returns one worth; in any other case, it returns one other worth.
The format of a system utilizing IF is
=IF(Argument, Worth IF TRUE, Worth IF FALSE). For instance, as proven under,
=IF(E2=1,3,4) causes IF to return the quantity Three if cell E2 equals 1; in any other case, it returns the quantity 4.
As a result of IF solely helps a single argument, you should use AND and OR to introduce complicated logical checks with a number of arguments.
Utilizing AND with IF
To make use of AND inside an IF system, kind
=IF(AND(AND Argument 1), Worth IF TRUE, Worth IF FALSE), and change your AND argument (or arguments), and IF TRUE and IF FALSE values.
In our instance under, we used IF with a nested AND system in cell A2 with 4 arguments. All 4 arguments are appropriate, so the IF TRUE worth (on this case, “Sure,”) is returned.
In cell A3, an identical IF with AND system comprises two incorrect arguments. As AND requires all arguments to be appropriate, IF returns the IF FALSE worth, which is a distinct textual content worth (“No”).
Utilizing OR with IF
The identical as with AND, you too can use OR with IF to create a fancy logical take a look at. Just one OR argument needs to be appropriate for IF to return a TRUE response.
To make use of OR with IF, click on an empty cell and sort
=IF(OR(OR Argument 1), Worth IF TRUE, Worth IF FALSE).
Change the OR argument (or arguments), and your IF TRUE/FALSE values, as required.
In our examples under, the 2 IF with OR formulation in cells A2 and A3 returned the IF TRUE textual content worth (“Sure”). All 4 arguments are appropriate within the A2 IF with OR system, whereas A3 has two incorrect arguments out of 4.
In cell A4, all 4 arguments within the IF with OR system are incorrect. Because of this the general IF system returns the IF FALSE textual content worth (“No”), as a substitute.