# Sumproduct count unique items

#### dfenton21

##### Board Regular
Hi,
I'm using the following SUMPRODUCT formula to emulate a countif with multiple criteria functionality.

The paramaters are:
Column B contains dates
Column N contains an Item ID number
Cell H13 is a date
Cell H14 is a date

=SUMPRODUCT((B1:B9885>H13)*(N1:N9885=B14))-SUMPRODUCT(B1:B9885>H14)*(N1:N9885=B14))

So, the formula returns the number of times the Item ID occurs between the two specified dates.

If I have a third column containing customer names, is it possible to modify to above formula to return the number of times the Item ID occurs between the two specified date, but only for unique customers

For example,
CUSTOMER ¦ ITEM ID
Name1 ¦ 999
Name1 ¦ 999
Name2 ¦ 999
Name3 ¦ 999
Name2 ¦ 999
Name3 ¦ 999

The formula should return 1, when looking for Name1 and 999 assuming the above information is within the specified date range.

I could probably do this in VBA, but would rather use a formula.

Thanks.

### Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},\$Z\$1:\$Z\$99,\$Y\$1:\$Y\$99),2,False) to lookup Y values to left of Z values.

#### Jerry Sullivan

##### MrExcel MVP
Hi Damien,

You might try:

Code:
``=SUMPRODUCT((B1:B9885>=H13)*(B1:B9885<=H14)*(M1:M9885="Name1")*(N1:N9885="999"))<?XML:NAMESPACE PREFIX = H14)*(M1 /><H14)*(M1:M9885="Name1")*(N1:N9885="999"))<?XML:NAMESPACE PREFIX="H14)*(M1"></H14)*(M1:M9885="Name1")*(N1:N9885="999"))<?XML:NAMESPACE><H14)*(M1:M9885="Name1")*(N1:N9885="999"))< p>``

Where:
Your desired dates fall within the dates in H13 and H14 inclusively.
Column M has your Customer Names
Column N has your Item IDs'

Your formula seemed to be referencing B14 as the Cell that has your ID criteria, which confused me since Column B is used for your dates. Not sure if that was a typo or my misunderstanding.

Hope this helps!
</H14)*(M1:M9885="Name1")*(N1:N9885="999"))<>

Last edited:

#### dfenton21

##### Board Regular
Hi,

The solution seems so obvious once I see it!

And yes, the ID reference was a typo (it's actually column B in another sheet).

Replies
2
Views
48
Replies
13
Views
388
Replies
1
Views
29
Replies
1
Views
78
Replies
6
Views
116