You are on page 1of 5

LOGIC

Page 12 - 1

BOOLEAN ALGEBRA AND THE


"IF" STATEMENT

12

ENGINEERING with the SPREADSHEET


Copyright 2006 American Society of Civil Engineers
A

7:44
05/05/15

269039198.xls

OVERVIEW
Math operators <, >, =, <=, >=
Dog
3 unit
Fox
4 unit
Result

Christy

Note: it is often wise to show the formula used.


Another aid in constructing and reviewing
spreadsheets is to show the numbers in a
concatenated string.

1 logic
=Dog<Fox
3 Dog(s) < 4 Fox(s)

In this case, the IF statement uses the Boolean


output of another cell to return a text statement.

IF statements
Result_2 More foxes

row 20
=IF(Result,"More foxes","More dogs")

The Boolean statement may be contained within the IF statement


quantity
2 unit
2 Foxes
string

When using MIN( ) and MAX ( ) functions,


where the logic value true = 1, the 1 must
operate on another number to be recognized.
For example:

formula
text
formula
=IF(quantity=1 , "1 Fox" , FIXED(quantity,0,TRUE) & " Foxes")
It could also return the result of a formula within the IF statement or reference a
result from outside of the statement and returned from within the IF statement.
A
1
B
More foxes
C
2 Foxes
Answer
More foxes
The equation using range names:

A
=Dog<Fox

a.

MIN( 1, 2, 3)
returns 2 if the 1 references
a logic result

b. MIN( 1*1, 2, 3)
returns 1 because the logic
result operates on another
number

B
=IF(Result,"More foxes","More dogs")
C
=IF(quantity=1,"1 Fox",FIXED(quantity,0,TRUE)&" Foxes")

=IF ( A, B, C_ )
PARK AND CONCATENATE
An equation can be easily parked and copied without changing the references.
The following example equations use numbers only.
Equation D
2
Press the [F2] edit key. Press the [Home] key to go to the front of the equation. Press the [Space Bar] to insert
a space and turn the equation into plain text. This yields:
=(1+1)
Equation E
4
converts to =(2+2)
Create this equation, = D +E , by concatenation.
=(1+1) +
Add the "+" operator
=(2+2)
now to keep the
process simple or add
it later if you forget.
Justify the range to create a text string on one row.
=(1+1) + =(2+2)
Figure 12-1 Concatenation with Justify command.
Now clean up the text by removing the = operator at mid-string and the space at the beginning of the string.
Equation F
6
Inserting a space or a comma in front of an equation also works well to put a malfunctioning equation on hold.

row 50

row 60

LOGIC

Page 12 - 2

BOOLEAN ALGEBRA AND THE


"IF" STATEMENT

12

ENGINEERING with the SPREADSHEET


Copyright 2006 American Society of Civil Engineers
A

Christy
7:44
05/05/15

269039198.xls
E

row 70

LOGIC

Page 12 - 3

BOOLEAN ALGEBRA AND THE


"IF" STATEMENT

12

ENGINEERING with the SPREADSHEET


Copyright 2006 American Society of Civil Engineers
A

Christy
7:44
05/05/15

269039198.xls
E

PARK, CONCATENATE, AND JUSTIFY

Add this button to your tool bar with


Tools, Customize, Commands, Edit, and Justify.
Drag this selection to the tool bar.
row 80

row 90
Figure 12-2 Adding a button to your tool bar in the Customize window.
RANGE NAMES IN EQUATIONS
Dogs
3 unit
Foxes
4 unit
Result
1 logic
Show the equation with its range names, not cell R1C1 references.
1
parked and copied from above
Press the [F2] key to edit the equation in the equation window.

row 100

Figure 12-3 Range names in the formula bar.


Place the mouse pointer over or in front of the = sign and press the [space bar].
Press [Return] and the equation under the cursor will turn from an
equation of cell references to an equation of range name references.
This equation has been parked as text and can be copied to a comments area.
1 =Dogs<Foxes
row 110
This method provides an audit trail or map of the logic process. A
good audit trail is important for verifying the template design.
OTHER LOGIC FUNCTIONS
IF
(condition, x, y)
CHOOSE (x, v0, v1..vn)
VLOOKUP (x, range, column offset number)
HLOOKUP (x, range, row offset number)
MIN
MAX
#NOT#
#AND#
#OR#

(range_1, range_2,..range_n, value, formula)


(range_1, range_2,..range_n, value, formula)
logical NOT
logical AND
logical OR

row 120

LOGIC

Page 12 - 4

BOOLEAN ALGEBRA AND THE


"IF" STATEMENT

12

ENGINEERING with the SPREADSHEET


Copyright 2006 American Society of Civil Engineers
A

Christy
7:44
05/05/15

269039198.xls

row 130
THE LOGIC SIEVE, BOOLEAN ALGEBRA, and BOOLEAN OPERATORS
Here we use two Boolean expressions to yield a 1 or a 0 for A, BB, or BC.
If one criteria or the other isn't met (i.e. Number not< 2), then at least
one 0 is returned and B0*B0 or B0*B1 equals B0.
Three methods for creating a logic sieve are used in this example.
You may substitute numbers or formulas for A, B, and C in Example A.
Example A
Number

Input

A
B
C

1
1
1

Number <= 1
Number <= 2
Number <= 3

Choice

row 140

A
A

Example B
A
B
C
Choice

Nested IF statement for text or numbers


@Choose(x,n1..)
for text or numbers
row 150
1
0
0

0 < Number <= 1


1 < Number <= 2
2 < Number <= 3

A
B
C

Concatenated IF statements for text

row 160

BOOLEAN TABLE

not A
A xor B
A=B
A<>B

A or B

A nor B
A nand B

A<B

A>B

A and B

1
1
0
0

1
0
1
0

0
0
1
0

0
1
0
0

1
0
0
1

0
1
1
0

1
0
0
0

1
1
1
0

0
0
1
1

0
1
1
1

0
0
0
1

T
T
F
F

T
F
T
F

0
0
1
0

0
1
0
0

1
0
0
1

0
1
1
0

1
0
0
0

1
1
1
0

0
0
1
1

0
1
1
1

0
0
0
1

row 180

LOGIC

Page 12 - 5

BOOLEAN ALGEBRA AND THE


"IF" STATEMENT

12

ENGINEERING with the SPREADSHEET


Copyright 2006 American Society of Civil Engineers
A

Christy
7:44
05/05/15

269039198.xls
E

row 190

You might also like