SUMPRODUCT or COUNTIF for weekday + multiple text criteria?

tsusan

New Member
Joined
Jul 22, 2017
Messages
4
In the following table I would like to count how many times EITHER 'apple' OR 'pear' appears on a Saturday. (Note that sometimes BOTH 'apple' and 'pear' appear on a Saturday, but they should only be counted once. So the correct answer should yield 3 out of the 4 Saturdays in this table.)

Column A uses "date" formatting. Columns B and C are text only.

I'm pretty sure I want to use a SUMPRODUCT with some kind of WEEKDAY syntax for Column A and some kind of multiple text criteria for Columns B and C, but I'm not sure how to do that. I know how to COUNTIF multiple text criteria, but I don't know how to SUMPRODUCT that with the Column A data.

Thanks in advance.


ABC
Saturday, July 22, 2017

<tbody>
</tbody>
applekiwi
Friday, July 21, 2017

<tbody>
</tbody>
jackfruitdurian
Thursday, July 20, 2017

<tbody>
</tbody>
kiwijackfruit
Wednesday, July 19, 2017

<tbody>
</tbody>
kiwikiwi
Tuesday, July 18, 2017

<tbody>
</tbody>
applekiwi
Monday, July 17, 2017

<tbody>
</tbody>
jackfruitkiwi
Sunday, July 16, 2017

<tbody>
</tbody>
kiwipear
Saturday, July 15, 2017

<tbody>
</tbody>
pearapple
Friday, July 14, 2017

<tbody>
</tbody>
kiwikiwi
Thursday, July 13, 2017

<tbody>
</tbody>
durianjackfruit
Wednesday, July 12, 2017

<tbody>
</tbody>
kiwikiwi
Tuesday, July 11, 2017

<tbody>
</tbody>
kiwikiwi
Monday, July 10, 2017

<tbody>
</tbody>
jackfruitdurian
Sunday, July 9, 2017

<tbody>
</tbody>
kiwikiwi
Saturday, July 8, 2017

<tbody>
</tbody>
kiwikiwi
Friday, July 7, 2017

<tbody>
</tbody>
applekiwi
Thursday, July 6, 2017

<tbody>
</tbody>
jackfruitkiwi
Wednesday, July 5, 2017

<tbody>
</tbody>
kiwipear
Tuesday, July 4, 2017

<tbody>
</tbody>
duriankiwi
Monday, July 3, 2017

<tbody>
</tbody>
durianjackfruit
Sunday, July 2, 2017

<tbody>
</tbody>
peardurian
Saturday, July 1, 2017

<tbody>
</tbody>
pearjackfruit

<tbody>
</tbody>
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Maybe

=SUMPRODUCT(--(WEEKDAY(A2:A23)=7),SIGN((B2:B23="apple")+(C2:C23="apple")+(B2:B23="pear")+(C2:C23="pear")))
 
Upvote 0
My suggestion works but I like Tetra201's suggestion.

=SUMPRODUCT(--(WEEKDAY(A2:A23)=7),--(((B2:B23="apple")+(B2:B23="pear")+(C2:C23="apple")+(C2:C23="pear"))>0))
 
Upvote 0
Thank you both. What if Column B & C are a named range? Could I sub in the named range for B2:B23 and/or C2:C23? Should that work just as effectively?
 
Upvote 0
Don't see why not -- as long as the ranges are of the same size and do not cover the entire column.
 
Upvote 0
Alas, it doesn't seem to like it with a named range. Here's what I was actually trying to do based on your model (I used apples and pears to keep it simple in the original example, but my real data is short alphanumeric combos).

This is what worked:
=SUMPRODUCT(--(WEEKDAY(A2:A209)=7),SIGN((B2:B209="XXI")+(C2:C209="XXI")+(B2:B209="8C")+(C2:C209="8C")+(B2:B209="7D")+(C2:C209="7D")+(B2:B209="5W")+(C2:C209="5W")+(B2:B209="3S")+(C2:C209="3S")+(B2:B209="10W")+(C2:C209="10W")))


This is what didn't work, after I tried to sub B2:B209 and C2:C209 with the named range (which covers B2:C209):

=SUMPRODUCT(--(WEEKDAY(A2:A209)=7),SIGN((S2017Cards="XXI")+(S2017Cards="8C")+(S2017Cards="7D")+(S2017Cards="5W")+(S2017Cards="3S")+(S2017Cards="10W")))

The named range is working fine in a number of other formulas on the sheet, so I don't think it's the problem. I don't have to use it here - I just hoped I could because it seemed a little more elegant than the Column B + Column C solution. But clearly there's something Excel doesn't like about it!
 
Upvote 0
with your original example and named ranges

=SUMPRODUCT(--(WEEKDAY(rngA)=7),--(((rngB="apple")+(rngB="pear")+(rngC="apple")+(rngC="pear"))>0))

N.B. Each named range is the same length.

Try a distinct named range for each column.
 
Last edited:
Upvote 0
That seems to work! Thanks!

I guess the named range has to cover exactly the same number of cells in each of the components.

with your original example and named ranges

=SUMPRODUCT(--(WEEKDAY(rngA)=7),--(((rngB="apple")+(rngB="pear")+(rngC="apple")+(rngC="pear"))>0))

N.B. Each named range is the same length.

Try a distinct named range for each column.
 
Upvote 0

Forum statistics

Threads
1,214,985
Messages
6,122,606
Members
449,089
Latest member
Motoracer88

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top