ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Truth Table in Excel (https://www.excelbanter.com/excel-discussion-misc-queries/171959-truth-table-excel.html)

Jims

Truth Table in Excel
 
Good Morning,

I'm trying to incorporate a simple truth table. Basically, if x1=1 then y1
and z1=0, if y1=1 then x1 and z1=0, if z1=1 then x1 and y1 =0. Is there a way
to do this?
--
Thanks,
Jim

ExcelBanter AI

Answer: Truth Table in Excel
 
Creating a Truth Table in Excel

Good morning Jim,

Yes, you can create a truth table in Excel using logical functions such as IF, AND, and OR. Here are the steps to create the truth table based on your conditions:
  1. Open a new Excel spreadsheet and enter the following headers in cells A1, B1, and C1: "x1", "y1", and "z1".
  2. In cells A2, B2, and C2, enter the values 0 or 1 to represent the possible values of x1, y1, and z1.
  3. In cell D2, enter the following formula:
    Formula:

    =IF(A2=1,0,IF(B2=1,0,IF(C2=1,0,""))) 

  4. In cell E2, enter the following formula:
    Formula:

    =IF(B2=1,0,IF(A2=1,0,IF(C2=1,0,""))) 

  5. In cell F2, enter the following formula:
    Formula:

    =IF(C2=1,0,IF(A2=1,0,IF(B2=1,0,""))) 

  6. Copy the formulas in cells D2:F2 and paste them into the cells below to apply the formulas to the rest of the truth table.
  7. You should now have a truth table that shows the values of x1, y1, and z1, and the corresponding values of y1 and z1 if x1 is 1, x1 and z1 if y1 is 1, and x1 and y1 if z1 is 1.

iliace

Truth Table in Excel
 
It's been a while since I've studied logic, but don't you need to
define all values of operands for a truth table, and yield the answer
for each using an operator?

In other words, my idea of a truth table is like so, where #(n,m) is
the operator:

X1 Y1 Z1 X1#(Y1,Z1)
0 0 0 0
0 0 1 1
0 1 0 0
0 1 1 1
1 0 0 .... etc.


It's possible to do what you say as far as setting up the table, but I
fail to see how you would actually use it? If you can give an
example, perhaps that would help.



On Jan 7, 11:34 am, JimS wrote:
Good Morning,

I'm trying to incorporate a simple truth table. Basically, if x1=1 then y1
and z1=0, if y1=1 then x1 and z1=0, if z1=1 then x1 and y1 =0. Is there a way
to do this?
--
Thanks,
Jim



Jims

Truth Table in Excel
 
In this application I'm trying to have only 1 positive in a given set so my
truth table would look like this:
x1 y1 z1
1 0 0
0 1 0
0 0 1

If any single response is "1" then all others in that row should be "0". No
two columns should be positive in any one row. Does this clear things up or
muddy the waters further?
--
Thanks,
Jim


"iliace" wrote:

It's been a while since I've studied logic, but don't you need to
define all values of operands for a truth table, and yield the answer
for each using an operator?

In other words, my idea of a truth table is like so, where #(n,m) is
the operator:

X1 Y1 Z1 X1#(Y1,Z1)
0 0 0 0
0 0 1 1
0 1 0 0
0 1 1 1
1 0 0 .... etc.


It's possible to do what you say as far as setting up the table, but I
fail to see how you would actually use it? If you can give an
example, perhaps that would help.



On Jan 7, 11:34 am, JimS wrote:
Good Morning,

I'm trying to incorporate a simple truth table. Basically, if x1=1 then y1
and z1=0, if y1=1 then x1 and z1=0, if z1=1 then x1 and y1 =0. Is there a way
to do this?
--
Thanks,
Jim




Tyro[_2_]

Truth Table in Excel
 
You have your truth table. Now what?

tyro

"JimS" wrote in message
...
In this application I'm trying to have only 1 positive in a given set so
my
truth table would look like this:
x1 y1 z1
1 0 0
0 1 0
0 0 1

If any single response is "1" then all others in that row should be "0".
No
two columns should be positive in any one row. Does this clear things up
or
muddy the waters further?
--
Thanks,
Jim





iliace

Truth Table in Excel
 
I got that part. The problem is that a cell value can only come from
one source: formula or manual input. It cannot be both. In other
words, if you have the table you show in A1, then A2 would be a
manually entered value. B2 and C2 would have calculated values by
formula.

Along the lines of:

B2 = IF(OR(A2,C2),0)

What's not clear is what the formula should evaluate to if B2 is 0.
How would you determine whether Y or Z should be 1?

Another approach would be to do this programmatically. Let's say you
have an event trigger in your worksheet's code module, as follows:

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Me.Range("A2:C4")) Is Nothing Then
Dim rng As Excel.Range
Set Target = Target.Cells(1)
If Target.Value = 1 Then
For Each rng In Intersect(Target.EntireRow, Me.Range("A2:C4"))
If rng.Address < Target.Address Then
rng.Value = 0
End If
Next rng
End If
End If
End Sub

Any time a value of 1 is entered in range A2:C4, the other 2 values in
the same row are set to 0.

Again, there must be greater utility to doing this, but I cannot
gather what it is from your inquiry.

On Jan 7, 12:23 pm, JimS wrote:
In this application I'm trying to have only 1 positive in a given set so my
truth table would look like this:
x1 y1 z1
1 0 0
0 1 0
0 0 1

If any single response is "1" then all others in that row should be "0". No
two columns should be positive in any one row. Does this clear things up or
muddy the waters further?
--
Thanks,
Jim

"iliace" wrote:
It's been a while since I've studied logic, but don't you need to
define all values of operands for a truth table, and yield the answer
for each using an operator?


In other words, my idea of a truth table is like so, where #(n,m) is
the operator:


X1 Y1 Z1 X1#(Y1,Z1)
0 0 0 0
0 0 1 1
0 1 0 0
0 1 1 1
1 0 0 .... etc.


It's possible to do what you say as far as setting up the table, but I
fail to see how you would actually use it? If you can give an
example, perhaps that would help.


On Jan 7, 11:34 am, JimS wrote:
Good Morning,


I'm trying to incorporate a simple truth table. Basically, if x1=1 then y1
and z1=0, if y1=1 then x1 and z1=0, if z1=1 then x1 and y1 =0. Is there a way
to do this?
--
Thanks,
Jim



Jims

Truth Table in Excel
 
I would like to notify the user if there is more than 1 positive in a given
row by changing the cell background color (for example) and gettng the user
to correct the row before going on. Or accepting the last entry and changing
the other row entries.
This is being used in a patient care facility where each patient is
receiving 1 and only one level of care (appropriate for that patient). I am
essentially trying to "bullet-proof" the chart.

Would an IFSUM statement accomplish this?
ex. (IFSUM(x1:z11,(what syntax?)

--
Thanks,
Jim


"Tyro" wrote:

You have your truth table. Now what?

tyro

"JimS" wrote in message
...
In this application I'm trying to have only 1 positive in a given set so
my
truth table would look like this:
x1 y1 z1
1 0 0
0 1 0
0 0 1

If any single response is "1" then all others in that row should be "0".
No
two columns should be positive in any one row. Does this clear things up
or
muddy the waters further?
--
Thanks,
Jim






David Biddulph[_2_]

Truth Table in Excel
 
You could use data validation, requiring whole number, less than or equal
to:
=1-OR(X1,Y1) as the formula for Z1, and corresponding formulae for X1 and
Y1.
--
David Biddulph

"JimS" wrote in message
...
In this application I'm trying to have only 1 positive in a given set so
my
truth table would look like this:
x1 y1 z1
1 0 0
0 1 0
0 0 1

If any single response is "1" then all others in that row should be "0".
No
two columns should be positive in any one row. Does this clear things up
or
muddy the waters further?
--
Thanks,
Jim


"iliace" wrote:

It's been a while since I've studied logic, but don't you need to
define all values of operands for a truth table, and yield the answer
for each using an operator?

In other words, my idea of a truth table is like so, where #(n,m) is
the operator:

X1 Y1 Z1 X1#(Y1,Z1)
0 0 0 0
0 0 1 1
0 1 0 0
0 1 1 1
1 0 0 .... etc.


It's possible to do what you say as far as setting up the table, but I
fail to see how you would actually use it? If you can give an
example, perhaps that would help.



On Jan 7, 11:34 am, JimS wrote:
Good Morning,

I'm trying to incorporate a simple truth table. Basically, if x1=1 then
y1
and z1=0, if y1=1 then x1 and z1=0, if z1=1 then x1 and y1 =0. Is there
a way
to do this?
--
Thanks,
Jim






iliace

Truth Table in Excel
 
A non-intrusive way to do this (meaning, no pop-up dialogs) is using
conditional formatting. From the above example, highlight cell A2,
and enter this rule (Formula is):

=SUM($A2:$C2)1

Then go to Format and select a color you would like to highlight.
Finally, copy cell A2, select format painter and highlight your entire
data entry range. This will not prevent an error, but it will
highlight the row if there is more than one 1 in it. Of course you'll
have to adjust your range accordingly.

Hope that helps.


On Jan 7, 1:37 pm, JimS wrote:
I would like to notify the user if there is more than 1 positive in a given
row by changing the cell background color (for example) and gettng the user
to correct the row before going on. Or accepting the last entry and changing
the other row entries.
This is being used in a patient care facility where each patient is
receiving 1 and only one level of care (appropriate for that patient). I am
essentially trying to "bullet-proof" the chart.

Would an IFSUM statement accomplish this?
ex. (IFSUM(x1:z11,(what syntax?)

--
Thanks,
Jim

"Tyro" wrote:
You have your truth table. Now what?


tyro


"JimS" wrote in message
...
In this application I'm trying to have only 1 positive in a given set so
my
truth table would look like this:
x1 y1 z1
1 0 0
0 1 0
0 0 1


If any single response is "1" then all others in that row should be "0".
No
two columns should be positive in any one row. Does this clear things up
or
muddy the waters further?
--
Thanks,
Jim



Stan Brown

Truth Table in Excel
 
Mon, 7 Jan 2008 09:23:08 -0800 from JimS
:
In this application I'm trying to have only 1 positive in a given set so my
truth table would look like this:
x1 y1 z1
1 0 0
0 1 0
0 0 1

If any single response is "1" then all others in that row should be "0". No
two columns should be positive in any one row. Does this clear things up or
muddy the waters further?


You can't do it with formulas, because as soon as you type a value in
any cell, that wipes out the cell formula and then when you change
another cell the first cell won't change. So you'd have to write a
Worksheet_Change macro to sense what changed and adjust the other
cells.

--
Stan Brown, Oak Road Systems, Tompkins County, New York, USA
http://OakRoadSystems.com/
"If there's one thing I know, it's men. I ought to: it's
been my life work." -- Marie Dressler, in /Dinner at Eight/

Jims

Truth Table in Excel
 
Thanks Iliace. I think this is the best option. It seemed like a simple thing
when I first thought about it.
--
Thanks,
Jim


"iliace" wrote:

A non-intrusive way to do this (meaning, no pop-up dialogs) is using
conditional formatting. From the above example, highlight cell A2,
and enter this rule (Formula is):

=SUM($A2:$C2)1

Then go to Format and select a color you would like to highlight.
Finally, copy cell A2, select format painter and highlight your entire
data entry range. This will not prevent an error, but it will
highlight the row if there is more than one 1 in it. Of course you'll
have to adjust your range accordingly.

Hope that helps.


On Jan 7, 1:37 pm, JimS wrote:
I would like to notify the user if there is more than 1 positive in a given
row by changing the cell background color (for example) and gettng the user
to correct the row before going on. Or accepting the last entry and changing
the other row entries.
This is being used in a patient care facility where each patient is
receiving 1 and only one level of care (appropriate for that patient). I am
essentially trying to "bullet-proof" the chart.

Would an IFSUM statement accomplish this?
ex. (IFSUM(x1:z11,(what syntax?)

--
Thanks,
Jim

"Tyro" wrote:
You have your truth table. Now what?


tyro


"JimS" wrote in message
...
In this application I'm trying to have only 1 positive in a given set so
my
truth table would look like this:
x1 y1 z1
1 0 0
0 1 0
0 0 1


If any single response is "1" then all others in that row should be "0".
No
two columns should be positive in any one row. Does this clear things up
or
muddy the waters further?
--
Thanks,
Jim





All times are GMT +1. The time now is 12:32 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com