count open records per month

deb

Active Member
Joined
Feb 1, 2003
Messages
400
Access 2010

I have a table, t_Orders, with the following fields.. OrderNo, OpenedDate, ClosedDate.

OrderNo, OpenedDate, ClosedDate.
12345 1/1/2017 1/10/2017
12346 1/10/2017 3/5/2017
12347 3/4/2017 4/4/2017
12348 2/20/2017 3/22/2017

I need to count how may records are open per month.

Should look something like this:

Jan2017 Feb2017 Mar2017 Apr2017
2 2 3 1

Don't even know where to start with this one.
Data above is simplified, actual data is over 50k records spanning over many years.
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
Oeder NoOpenDateClosedDate
123451/25/20171/10/2017
123461/10/20173/5/2017
123473/4/20174/4/2017
123482/20/20173/22/2017
123494/25/20175/10/2017
123501/10/20176/10/2017
Jan-17Feb-17Mar-17Apr-17May-17Jun-17
334321
For Jan =


Code:
=COUNTIFS($B$2:$B$8,">="&(A10),$B$2:$B$8,"<="&EOMONTH(A10,0))

For Other Month
Code:
=COUNTIFS($B$2:$B$8,"<="&EOMONTH(B10,-1)+1,$C$2:$C$8,">="&B10)+COUNTIFS($B$2:$B$8,">="&(B10),$B$2:$B$8,"<="&EOMONTH(B10,0))

<colgroup><col span="3"><col span="3"></colgroup><tbody>
</tbody>
 
Upvote 0
I think the first response is confusing this with Excel when this is an Access question, for I don't believe there's a CountIf function in Access so I'll answer as an Access question.

It depends on what constitutes an "open" record. The fact that there is an open date? That there is an open but not a closed date? That a date is less than the current date? Looking at your expected results, I can't arrive at 2 for February no matter how I interpret "open". I notice that you seem to want to put the results in columns rather than rows, which could mean this is for Excel, since Access is row based data and is harder to put into columns. If "open" means there's an open date regardless of anything else, a query like
Code:
SELECT [t_Orders].OpenedDate, Count([t_Orders].OpenedDate) AS CountOfOpenedDate
FROM [t_Orders]
GROUP BY [t_Orders].OpenedDate
HAVING ((([t_Orders].OpenedDate) Is Not Null));
Basically, I suspect you might need to create a Totals query first, then if you must have the rows as columns, create a Crosstab query using the Totals query as a table. If you don't really need data in columns, then I'd forget it since it can introduce a new set of problems.
By the time you read this, I might have gone away for a few days. You can always research Totals and Crosstab queries for Access.
 
Upvote 0

Forum statistics

Threads
1,214,805
Messages
6,121,665
Members
449,045
Latest member
Marcus05

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