Count instances of a rows that falls between 2 dates

Robb

Board Regular
Joined
Feb 17, 2002
Messages
145
My formula does not work correctly because it doesn't count all instances from Sheet A and I'm not sure why.

Sheet B contains my Date Criteria & formula to count the instances:
A16 = 25 May 2015
B16 = 29 May 2015

=COUNTIFS(Sheet A!$J$5:$J$5000,">="&A$16,Sheet A!$J$5:$J$5000,"<="&B$16,Sheet A!$D$5:$D$5000,"Bug")

Sheet A contains all the raw data:
D = Types of Issue (Bug, Improvement, Task, etc)
J = Created Date

Why would it count 16 out of 27?
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.

Asala42

Well-known Member
Joined
Feb 26, 2002
Messages
2,318
The formula looks okay on the surface. I'd check the data again. Use a filter on the above example to isolate the 27 you expect. Some possibilities are:

- Some dates are being treated as text. The 16 might equate to those equal to the above 2 dates only for example.
- Some entries might be not actually exact (such as trailing spaces: "Bug " vs "Bug")
 

Robb

Board Regular
Joined
Feb 17, 2002
Messages
145
You are on to something.
- dates are in my raw data sheet are displaying like this 5/29/2015 2:47:00 PM, not sure if that makes a difference. When I formatted the column into a date format it still didn't resolve the problem. However, when I typed the actual date over the raw data date, my 27 count appeared. Must have something to do with the format of the date or is treated like a text....thanks!!
 

Snakehips

Well-known Member
Joined
May 17, 2009
Messages
5,578
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
Robb,

I think you will find that it is the time element of your 'date' that is causing the issue.

Try the following that uses the integer of your date/time values so that the time element is ignored when testing >= & <=


Excel 2007
C
165
Sheet B
Cell Formulas
RangeFormula
C16=SUMPRODUCT((SheetA!$D$5:$D$5000="Bug")*(INT(SheetA!$J$5:$J$5000)>=A16)*(INT(SheetA!$J$5:$J$5000)<=B16))


Hope that helps.
 

Robb

Board Regular
Joined
Feb 17, 2002
Messages
145

ADVERTISEMENT

Thanks Snakehips, time element on the date was the problem and your formula returns the correct value. Thanks for everyone's input and help!
 

Robb

Board Regular
Joined
Feb 17, 2002
Messages
145
I can't figure out how to use multiple criteria with SUMPRODUCT formula.

Sheet A contains all the raw data:
D = Issue Type (Bug, Improvement, Task, etc)
E = Issue Status (Open, In Progress, Reopened, Resolved, Closed)
J = Created Date (format = 5/29/2015 2:47:16 PM)

I need to count the following:
Count all Bug issues that are <> CLOSED and date is less than Jun 1st

D = "Bug" Where
E = "Open + In Progress + Reopened + Resolved" AND
J = Less Than 01-Jun-15
 

Snakehips

Well-known Member
Joined
May 17, 2009
Messages
5,578
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
Robb,

For that scenario try......

Excel 2007
ABCDEFGHIJ
1DateBug Count
201/06/20152
3
4IssueStatusDate
5BugOpen25/05/2015
6TaskResolved26/05/2015
7TaskOpen03/01/2015
8ImprovementOpen04/01/2015
9BugOpen26/05/2015
10BugClosed26/05/2015
11TaskOpen07/01/2015
12BugOpen01/06/2015
SheetA
Cell Formulas
RangeFormula
B2=SUMPRODUCT((SheetA!$D$5:$D$5000="Bug")*(INT(SheetA!$J$5:$J$5000))*(SheetA!$E$5:$E$5000<>"Closed"))


In basic terms, each bracketed element, separated by '*', of the SUMPRODUCT expression returns an array of values.
The '*' both acts as a logical AND and converts TRUE's and FALSE's within the arrays to 1's and 0's so as to allow a numeric result.
(Using a '+' to separate parameter arrays equates to a logical OR)

Hope that helps.
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,168,204
Messages
5,857,907
Members
431,907
Latest member
RNN

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
Top