17.3 Conditional Statements
Beyond searching, Boolean logic is commonly used in spreadsheet applications like Excel to do conditional calculations. A statement is something that is either true or false. A statement like 3 < 5 is true; a statement like “a rat is a fish” is false. A statement like “” is true for some values of and false for others. When an action is taken or not depending on the value of a statement, it forms a conditional.
In other words, this statement is equivalent to saying “If the value of A1 is less than 2000, then add 1 to the value in A1. Otherwise, multiply A1 by 2”.
As we did earlier, we can create more complex conditions by using the operators and, or, and not to join simpler conditions together.
Suppose you wanted to have something happen when a certain value is between 100 and 300. To create the condition “A1 < 300 and A1 > 100” in Excel, you would need to enter “AND(A1<300, A1>100)”. Likewise, for the condition “A1=4 or A1=6” you would enter “OR(A1=4, A1=6)”
Adapted from Math in Society by David Lippman, hosted on LibreTexts (math.libretexts.org) and licensed under CC BY-SA 3.0. Changes were made. License: CC-BY-SA-3.0.