Sumproduct vs countif

S

Scott Kieta

I am trying to count the # of times a value occurs in a column, the column
format is dd/mm/yyyy hh:mm AM/PM and i want to count all occurrences between
7am and 8am, 8-9, 9-10, etc and have utilized this formula

=SUMPRODUCT((HOUR($I$15:$I$350)>=7)*(HOUR($I$15:$I$350)<8))

and it seems to work, however with the midnight to 1 am

=SUMPRODUCT((HOUR($I$15:$I$350)>=0)*(HOUR($I$15:$I$350)<1))

it is returning the blank cells as well how can i adjust this to not count
the blank cells, also is there an easier countif formula that could do the
same thing?
Thank You
 
L

Lars-Åke Aspelin

I am trying to count the # of times a value occurs in a column, the column
format is dd/mm/yyyy hh:mm AM/PM and i want to count all occurrences between
7am and 8am, 8-9, 9-10, etc and have utilized this formula

=SUMPRODUCT((HOUR($I$15:$I$350)>=7)*(HOUR($I$15:$I$350)<8))

and it seems to work, however with the midnight to 1 am

=SUMPRODUCT((HOUR($I$15:$I$350)>=0)*(HOUR($I$15:$I$350)<1))

it is returning the blank cells as well how can i adjust this to not count
the blank cells, also is there an easier countif formula that could do the
same thing?
Thank You

If you don't want to include the blank cells you can add an extra
multiplication, like this:

=SUMPRODUCT((HOUR($I$15:$I$350)>=0)*(HOUR($I$15:$I$350)<1)*(NOT(ISBLANK($I$15:$I$350))))

Hope this helps / Lars-Åke
 
L

Lars-Åke Aspelin

If you don't want to include the blank cells you can add an extra
multiplication, like this:

=SUMPRODUCT((HOUR($I$15:$I$350)>=0)*(HOUR($I$15:$I$350)<1)*(NOT(ISBLANK($I$15:$I$350))))

Hope this helps / Lars-Åke


And you dont need both >=0 and <1. Only =0 is needed, like this:

=SUMPRODUCT((HOUR($I$15:$I$350)=0)*(NOT(ISBLANK($I$15:$I$350))))

Lars-Åke
 
S

ShaneDevenshire

Hi Scott,

In addition you could use the shorter version

=countif(HOUR($I$15:$I$350)<1)


I'm assuming you don't have negative times.
 
S

Scott Kieta

Thank you, worked like a charm

Lars-Ã…ke Aspelin said:
And you dont need both >=0 and <1. Only =0 is needed, like this:

=SUMPRODUCT((HOUR($I$15:$I$350)=0)*(NOT(ISBLANK($I$15:$I$350))))

Lars-Ã…ke
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Sumproduct multiple criteria 6
count unique records 14
Countif Question 4
Excel Sumproduct 0
Sumproduct query 9
Counting occurances based on multiple variables 4
SUMPRODUCT help 3
COUNTIF PROBLEM 6

Top