Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 158
Default Sumproduct with OR

I'm sure there's a way to simplify this but not seeing it in any of the
previous answers. I have a SUMPRODUCT function where the first factor has a
lot of acceptable conditions, and I want to combine them somehow:

=SUMPRODUCT(--(RangeA="A"),--(RangeB="Baltimore))+SUMPRODUCT(--(RangeA="C"),--(RangeB="Baltimore))+SUMPRODUCT(--(RangeA="G"),--(RangeB="Baltimore)) . . .

The only thing changing is the condition in the first factor. rather than
repeat the whole function and add the results together, ideally I could
recode this mess somehow as "=SUMPRODUCT(--(RangeA=OR("A","C","G", . .
..),--(RangeB="Baltimore")). Any ideas? TIA
  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 158
Default Sumproduct with OR

I'm almost there but one complication. I realized my cells in RangeA do not
= "A" or "B" or "C", they contain "A" and/or "B" and/or "C". I got past that
with the trusty ISNUMBER(SEARCH("A",RangeA)), but those plus signs between
factors are making me count multiple occurences. My SUMPRODUCT result is
looking like 2,2,1,0,3,2 etc. when, instead, I want it to produce a "1" when
the cell contains at least one match and 0 if no matches. Can this be
tweaked of do I need a whole new approach? TIA

"Sandy Mann" wrote:

In SUMPRODUCT() formulas multiplication acts like an AND() statement and
addition acts like an OR() statement so try:

=SUMPRODUCT(((RangeA="A")+(RangeA="B")+(RangeA="C" ),--(RangeB="Baltimore))

--
HTH

Sandy
In Perth, the ancient capital of Scotland
and the crowning place of kings


Replace @mailinator.com with @tiscali.co.uk


"andy62" wrote in message
...
I'm sure there's a way to simplify this but not seeing it in any of the
previous answers. I have a SUMPRODUCT function where the first factor has
a
lot of acceptable conditions, and I want to combine them somehow:

=SUMPRODUCT(--(RangeA="A"),--(RangeB="Baltimore))+SUMPRODUCT(--(RangeA="C"),--(RangeB="Baltimore))+SUMPRODUCT(--(RangeA="G"),--(RangeB="Baltimore))
. . .

The only thing changing is the condition in the first factor. rather
than
repeat the whole function and add the results together, ideally I could
recode this mess somehow as "=SUMPRODUCT(--(RangeA=OR("A","C","G", . .
.),--(RangeB="Baltimore")). Any ideas? TIA




  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2,345
Default Sumproduct with OR

This seems to work:

=SUMPRODUCT(--((ISNUMBER(SEARCH("A",RangeA)))+(ISNUMBER(SEARCH(" B",RangeA)))+(ISNUMBER(SEARCH("C",RangeA)))=1) ,--(RangeB="Baltimore"))

--
HTH

Sandy
In Perth, the ancient capital of Scotland
and the crowning place of kings


Replace @mailinator.com with @tiscali.co.uk


"andy62" wrote in message
...
I'm almost there but one complication. I realized my cells in RangeA do
not
= "A" or "B" or "C", they contain "A" and/or "B" and/or "C". I got past
that
with the trusty ISNUMBER(SEARCH("A",RangeA)), but those plus signs between
factors are making me count multiple occurences. My SUMPRODUCT result is
looking like 2,2,1,0,3,2 etc. when, instead, I want it to produce a "1"
when
the cell contains at least one match and 0 if no matches. Can this be
tweaked of do I need a whole new approach? TIA

"Sandy Mann" wrote:

In SUMPRODUCT() formulas multiplication acts like an AND() statement and
addition acts like an OR() statement so try:

=SUMPRODUCT(((RangeA="A")+(RangeA="B")+(RangeA="C" ),--(RangeB="Baltimore))

--
HTH

Sandy
In Perth, the ancient capital of Scotland
and the crowning place of kings


Replace @mailinator.com with @tiscali.co.uk


"andy62" wrote in message
...
I'm sure there's a way to simplify this but not seeing it in any of the
previous answers. I have a SUMPRODUCT function where the first factor
has
a
lot of acceptable conditions, and I want to combine them somehow:

=SUMPRODUCT(--(RangeA="A"),--(RangeB="Baltimore))+SUMPRODUCT(--(RangeA="C"),--(RangeB="Baltimore))+SUMPRODUCT(--(RangeA="G"),--(RangeB="Baltimore))
. . .

The only thing changing is the condition in the first factor. rather
than
repeat the whole function and add the results together, ideally I could
recode this mess somehow as "=SUMPRODUCT(--(RangeA=OR("A","C","G", . .
.),--(RangeB="Baltimore")). Any ideas? TIA







  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 806
Default Sumproduct with OR

Hello,

=SUMPRODUCT(SIGN(orcond1+orcond2+...),--andcond2,...)

Regards,
Bernd



  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 733
Default Sumproduct with OR

"Sandy Mann" wrote...
This seems to work:

=SUMPRODUCT(--((ISNUMBER(SEARCH("A",RangeA)))
+(ISNUMBER(SEARCH("B",RangeA)))+(ISNUMBER(SEARCH( "C",RangeA)))=1),
--(RangeB="Baltimore"))

....

It should work, but there are shorter ways to do this.

=SUMPRODUCT(--(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(rangeA,"A",""),
"B",""),"C","")<rangeA),--(RangeB="Baltimore"))

which doesn't scale up well, or

=SUMPRODUCT(--(MMULT(--ISNUMBER(SEARCH({"A","B","C"},rangeA)
/(rangeB="Baltimore")),{1;1;1})0))

which does.

  #7   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 158
Default Sumproduct with OR

Thnaks, I appreciate the shortcut since, in reality, my search includes 13
items, not just the three I simplified down to in my query. I implemented
Sandy's approach and it worked, but will try yours on the second one I have
to do.

"Harlan Grove" wrote:

"Sandy Mann" wrote...
This seems to work:

=SUMPRODUCT(--((ISNUMBER(SEARCH("A",RangeA)))
+(ISNUMBER(SEARCH("B",RangeA)))+(ISNUMBER(SEARCH( "C",RangeA)))=1),
--(RangeB="Baltimore"))

....

It should work, but there are shorter ways to do this.

=SUMPRODUCT(--(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(rangeA,"A",""),
"B",""),"C","")<rangeA),--(RangeB="Baltimore"))

which doesn't scale up well, or

=SUMPRODUCT(--(MMULT(--ISNUMBER(SEARCH({"A","B","C"},rangeA)
/(rangeB="Baltimore")),{1;1;1})0))

which does.


  #8   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3,718
Default Sumproduct with OR

Try this:

=SUMPRODUCT((RangeA={"A","B","C"})*(RangeB="Baltim ore"))


"andy62" wrote:

I'm sure there's a way to simplify this but not seeing it in any of the
previous answers. I have a SUMPRODUCT function where the first factor has a
lot of acceptable conditions, and I want to combine them somehow:

=SUMPRODUCT(--(RangeA="A"),--(RangeB="Baltimore))+SUMPRODUCT(--(RangeA="C"),--(RangeB="Baltimore))+SUMPRODUCT(--(RangeA="G"),--(RangeB="Baltimore)) . . .

The only thing changing is the condition in the first factor. rather than
repeat the whole function and add the results together, ideally I could
recode this mess somehow as "=SUMPRODUCT(--(RangeA=OR("A","C","G", . .
.),--(RangeB="Baltimore")). Any ideas? TIA

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sumproduct 6pak Excel Worksheet Functions 5 February 21st 07 02:07 PM
Sumproduct help Sandy Excel Worksheet Functions 4 February 20th 07 05:45 PM
sumproduct? anand Excel Worksheet Functions 2 December 11th 05 09:12 AM
Sumproduct Jeremy Ellison Excel Worksheet Functions 1 December 9th 05 09:45 PM
SUMPRODUCT Jim Excel Worksheet Functions 1 November 11th 05 04:58 AM


All times are GMT +1. The time now is 03:08 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"