View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.misc
Dallman Ross Dallman Ross is offline
external usenet poster
 
Posts: 390
Default Sumproduct question

In . com, wx4usa
spake thusly:

I just want to count the number of entries, not a sum of
totals. column A is Month, B is Day, C is year, D is Name


Month is a word.


I don't understand your objection to SUMPRODUCT. It seems
to me to be the easiest approach here.

Suppose something like this:

Month Day Year Salesperson
Jan 1 2005 Phil
Feb 2 2006 Mary
Mar 3 2007 Phil
Apr 4 2008 Debra
Jan 1 2005 Pete
Jan 1 2004 Phil
Jan 1 2005 Phil
Feb 2 2006 Mary
Mar 3 2007 Phil
Apr 4 2008 Debra
Jan 1 2005 Pete
Jan 1 2004 Phil
Jan 1 2005 Phil
Feb 2 2006 Mary
Mar 3 2007 Phil
Apr 4 2008 Debra
Jan 1 2005 Pete
Jan 1 2004 Phil
Jan 1 2005 Phil
Feb 2 2006 Mary
Mar 3 2007 Phil
Apr 4 2008 Debra
Jan 1 2005 Pete
Jan 1 2004 Phil
Jan 1 2005 Phil
Feb 2 2006 Mary
Mar 3 2007 Phil


If you just use COUNTIF, you'll need a series of IF-statements
or, at best, a messy compound single IF-statement to count
the number of Phils on 1/1/2005. Or you could use SUMPRODUCT
as already shown.

=SUMPRODUCT(--($A$2:$A$28="Jan"),--($B$2:$B$28=1),--($C$2:$C$28=2005),--(D$2:$D$28="Phil"))

Okay, I just double-checked, and it doesn't seem to need to be an
array formula. Well, that's good, I guess.

You could also do it like this, allowing you to drag the formula
down and see the count for each line. Of course, you'll be
repeating information whenever the data repeats:

=SUMPRODUCT(--($A$2:$A$28=$A2),--($B$2:$B$28=$B2),--($C$2:$C$28=$C2),--(D$2:$D$28=$D2))

Another approach is to use a helper-column to combine
the dates. Then you could use COUNTIF easily. E.g., helper-column E2
could contain:

=VALUE(A2 & " " & B2 & ", " & C2)

Drag that down. You can format it as a date now if you want
and have it recognized as a date. At least it's an improvement
over three columns for the date. You could use SUMPRODUCT on
that, too, or use one IF-statement. Or put all the columns
togther as a text value in your helper-column, and use COUNTIF.

Others' comments would be apreciated to flesh this out further as
needed.

=dman=