Not sure if a COUNTIFS formula is the way to go

willow1985

Well-known Member
Joined
Jul 24, 2019
Messages
929
Office Version
  1. 365
Platform
  1. Windows
Hello,

Can anyone help me with a formula that counts invoice dates?

Not sure if CountIF can do this or not

Basically count how many items were invoiced in the current month and then another formula to count how many in the previous month Both for the current year.

The formulas I am currently using seem to have errors and do not account for the current year:
=SUMPRODUCT(--(TEXT('WO Report'!M2:M1000001,"mmyyyy")=TEXT(TODAY(),"mmyyyy")))
=SUMPRODUCT(--(TEXT('WO Report'!M2:M1000001,"mmyyyy")=TEXT(EDATE(TODAY(),-1),"mmyyyy")))

For the first formula I should be getting a result of 260 but I am getting a result of 266 and
for the 2nd I should be getting a result of 258 instead I am getting 269 and I do not know why.

Here is the data:

[TABLE="width: 530"]
<colgroup><col span="2"><col span="6"></colgroup><tbody>[TR]
[TD]Tab Names: WO Report[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]Tab Name: Tables[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Column M[/TD]
[TD][/TD]
[TD]Column V[/TD]
[TD][/TD]
[TD]Column S[/TD]
[TD][/TD]
[TD][/TD]
[TD]Current Month B14[/TD]
[/TR]
[TR]
[TD]Invoice Date[/TD]
[TD][/TD]
[TD]Month[/TD]
[TD][/TD]
[TD]Current Year[/TD]
[TD][/TD]
[TD][/TD]
[TD]Previous Month B15[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]2019-09-01[/TD]
[TD][/TD]
[TD]September[/TD]
[TD][/TD]
[TD]2019[/TD]
[TD][/TD]
[TD][/TD]
[TD]Formula[/TD]
[/TR]
[TR]
[TD]2019-09-25[/TD]
[TD][/TD]
[TD]September[/TD]
[TD][/TD]
[TD]2019[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]2019-08-11[/TD]
[TD][/TD]
[TD]August[/TD]
[TD][/TD]
[TD]2019[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]2018-08-01[/TD]
[TD][/TD]
[TD]August[/TD]
[TD][/TD]
[TD]2018[/TD]
[TD]

[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]

Answer should be for this data: 2 for current month and 1 for previous month

Thank you guys for your help!

Carla
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
I can't tell why it's not working without seeing the rest of your data. COUNTIFS might work for you though. Try:

=COUNTIFS('WO Report'!M:M,">"&EOMONTH(TODAY(),-1),'WO Report'!M:M,"<="&EOMONTH(TODAY(),0))

to count dates in the current month, and

=COUNTIFS('WO Report'!M:M,">"&EOMONTH(TODAY(),-2),'WO Report'!M:M,"<="&EOMONTH(TODAY(),-1))

to count dates in the previous month.
 
Upvote 0
Then I assume the dates in column M are text values, not Excel dates. If so, try:

=COUNTIF('WO Report'!M:M,TEXT(TODAY(),"yyyy-mm")&"*")

and

=COUNTIF('WO Report'!M:M,TEXT(EDATE(TODAY(),-1),"yyyy-mm")&"*")

And that could be your problem. If your column has a mixture of text and dates, the results from the formulas would be unreliable.
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,289
Members
452,631
Latest member
a_potato

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