
I've been taking a class on digital circuits and routinely have to create truth tables for a given circuit. After doing it by hand a few times, I turned to Excel to make things go faster.
Here's a sample circuit: Y = !ABC + AB + !A
It is sometimes also written as Y = A'BC + AB + A'.
How can Excel help generate the truth table?
Set up the structure
First I create a row with each discrete member of the expression in its own cell.
| A | B | C | !A | AB | !ABC | !ABC + AB + !A |
And I fill down the first three columns with the appropriate values. Since there are three discrete variables, there should be 23 rows of values to cover every possible combination of A, B and C.
| A | B | C |
| 0 | 0 | 0 |
| 0 | 0 | 1 |
| 0 | 1 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 0 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
| 1 | 1 | 1 |
First I fill down for A. Since there are 8 rows, the first four should be 0 and last four should be 1. For B, the first two should be zero, and so on. You can see that as you go from left to right, the values progressively switch from groups of 0's to 1's in half the time.
Another way to think of it is as a set of n-bit binary numbers from 0 to 2n. So with three variables, count from 0 to 7:
ABC
000
001
010
011
100
101
110
111
A is not !A
Now I need to figure out the value of !A. Since A can only equal 1 or 0, !A is always whatever A is not. So I use the following formula and fill down:
=IF([cell]=1,0,1)
Where [cell] is a reference to the cell containing the value for A. So now we have
| A | B | C | !A | AB | !ABC | !ABC + AB + !A |
| 0 | 0 | 0 | 1 | |||
| 0 | 0 | 1 | 1 | |||
| 0 | 1 | 0 | 1 | |||
| 0 | 1 | 1 | 1 | |||
| 1 | 0 | 0 | 0 | |||
| 1 | 0 | 1 | 0 | |||
| 1 | 1 | 0 | 0 | |||
| 1 | 1 | 1 | 0 |
Note that I could have also used =CHOOSE([cell]+1,1,0)
Logical AND Condition
Now we need to multiply A and B (AB) and !A with B and C (!ABC). If you recall from our discussion of truth tables, multiplication is the same as a logical AND.
So we'll use the following formula for AB: =AND([cellA],[cellB])*1
We could have also simply multiplied each cell: =[cellA]*[cellB]
We'll do the same thing with !ABC: =AND([cellA],[cellB],[cellC])*1
| A | B | C | !A | AB | !ABC | !ABC + AB + !A |
| 0 | 0 | 0 | 1 | 0 | 0 | |
| 0 | 0 | 1 | 1 | 0 | 0 | |
| 0 | 1 | 0 | 1 | 0 | 0 | |
| 0 | 1 | 1 | 1 | 0 | 1 | |
| 1 | 0 | 0 | 0 | 0 | 0 | |
| 1 | 0 | 1 | 0 | 0 | 0 | |
| 1 | 1 | 0 | 0 | 1 | 0 | |
| 1 | 1 | 1 | 0 | 1 | 0 |
Logical OR Condition
All that's left is to put everything together for the final expression. Recall that addition is the same as a logical OR condition. So to add the parts of the final expression, use the OR function.
!ABC + AB + !A = =OR([cellA],[cellB],[cellC])*1
Now our truth table is completed:
| A | B | C | !A | AB | !ABC | !ABC + AB + !A |
| 0 | 0 | 0 | 1 | 0 | 0 | 1 |
| 0 | 0 | 1 | 1 | 0 | 0 | 1 |
| 0 | 1 | 0 | 1 | 0 | 0 | 1 |
| 0 | 1 | 1 | 1 | 0 | 1 | 1 |
| 1 | 0 | 0 | 0 | 0 | 0 | 0 |
| 1 | 0 | 1 | 0 | 0 | 0 | 0 |
| 1 | 1 | 0 | 0 | 1 | 0 | 1 |
| 1 | 1 | 1 | 0 | 1 | 0 | 1 |
Screenshot:
Here are all the formulas used to create the truth table:

Download sample workbook — Excel 2003
Download sample workbook — Excel 2007





Interesting.
You could also simplify your !A formula with =–NOT([cell]) or =NOT([cell])*1
Sebastien
You're right, and I did start using NOT in the more recent iterations, but never bothered to add that to the article. Thanks for sharing!
Or…just to add one more possibility, simply:
=1-[cell]
because:
1-0=1
1-1=0
Rob
If you use TRUE and FALSE instead of 1 and 0, it's very easy, and you're working with true Boolean values:
!A =NOT(A)
AB =AND(A,B)
!ABC =AND(NOT(A),B,C)
!ABC + AB + !A =OR(AND(NOT(A),B,C),AND(B,C),NOT(A))
When the values are either boolean or integer:
=AND(A,B) can be written =A*B
=OR(A,B) can be written = A+B (but watch out for >=three condition ORs)
These return integers, not booleans
When the values are either boolean or integer:
=AND(A,B) can be written =A*B
=OR(A,B) can be written = A+B (but watch out for >=three condition ORs)
These return integers, not booleans
Someone posted (sorry – can't remeber who to credit) a quick Exlusive OR (XOR) function recently.
A XOR B = (NOT(A)*B)+(A*(NOT(B))
The fast way is:
A XOR B = NOT(A=B)
I think you are referring to this?
http://chandoo.org/wp/2010/03/02/either-or-formula-in-excel/