View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Elkar Elkar is offline
external usenet poster
 
Posts: 964
Default Summing a binary truth list

The SUMPRODUCT function should work well he

For just A, use:

=SUMPRODUCT(--(A1:A7="Y"),E1:E7)

For A and B, use:

=SUMPRODUCT(--(A1:A7="Y"),--(B1:B7="Y"),E1:E7)

For all 3, use:

=SUMPRODUCT(--(A1:A7="Y"),--(B1:B7="Y"),--(C1:C7="Y"),E1:E7)

Adjust these accordingly for whatever combination you need.

HTH,
Elkar


"Del Cotter" wrote:


For some reason I can't figure this one out. What's the most elegant way
to sum up a list of numbers according to a binary truth table? To start
with, here's an example of the raw data:

C B A Combo Numbers
N N N None 42
N N Y A only 23
N Y N B only 16
N Y Y A & B 26
Y N N C only 20
Y N Y A & C 11
Y Y N B & C 10
Y Y Y All 51

But now I want to add up all the rows in which, e.g. B has any part,
like so:

C B A Combo Numbers
N N Y A any 23+26+11+51=111
N Y N B any 16+26+10+51=103
N Y Y A & B 26+51=77
Y N N C any 20+11+10+51=92
Y N Y A & C 11+51=62
Y Y N B & C 10+51=61
Y Y Y All 51

I thought this would be easy, but I can't get my head around it. I'm
willing to change Y/N to binary TRUE/FALSE or 1/0 if it will make an
elegant function, but what function will best read the list above to
make the list below?

--
Del Cotter
NB Personal replies to this post will send email to ,
which goes to a spam folder-- please send your email to del3 instead.