countifs with date

errollflynn

New Member
Joined
Jan 25, 2021
Messages
24
Office Version
  1. 365
Platform
  1. Windows
Hello,

I've been banging my head against an issue I've been having with countifs. I have three ranges that I'm comparing.
The first column contains values 1-3 and I'm looking for 3. The second column contains the first day of a month i.e. 1/1/2021, 2/1/2021 etc. The third column also contains the first day of the month. I'm looking to count instances of where the first column has the value 3, the second has 6/1/2021 and the third has a date after the date in the second column. The formula I have is:

=COUNTIFS(Active!W3:W35,"3",Active!Z3:Z35,"6/1/2021",Active!AB3:AB35,">"&6/1/2021)

I'm getting 0 for a result. Based on how I understand the formula should work, row 9 should be counted.

COO Workforce Restoration Template MASTER 12.23.2020 JM.xlsx
WXYZAAAB
31
42Cat 15/1/2021
51
61
71
82Cat 17/1/2021
93Cat 26/1/2021Cat 17/1/2021
101
111
121
131
141
151
161
171
183Cat 27/1/2021Cat 17/1/2021
191
201
211
221
232Cat 15/1/2021
242Cat 18/1/2021
253Cat 28/1/2021Cat 18/1/2021
261
272Cat 15/1/2021
281
292Cat 17/1/2021
303Cat 24/1/2021Cat 16/1/2021
311
321
332Cat 14/1/2021
341
350
Active
Cells with Data Validation
CellAllowCriteria
Z21List='https://aegworldwide-my.sharepoint.com/personal/jmelendez_aegpresents_com/Documents/Mstr Cmpy Ovw 2020/WF Restoration Plan 2021/[Mkt Workforce Restoration Template MASTER 12.23.2020 BMK.xlsx]Date Criteria'!#REF!
Z4List='Date Criteria'!$A$2:$A$14
Z6List='Date Criteria'!$A$2:$A$14
Z13List='Date Criteria'!$A$2:$A$14
Z25:Z35List='Date Criteria'!$A$2:$A$14
AB11List='Date Criteria'!$A$2:$A$14
AB6List='Date Criteria'!$A$2:$A$14
Z15List='Date Criteria'!$A$2:$A$14
AB32:AB35List='Date Criteria'!$A$2:$A$14
AB9List='Date Criteria'!$A$2:$A$14
AB18List='Date Criteria'!$A$2:$A$14
AB25List='Date Criteria'!$A$2:$A$14
AB30List='Date Criteria'!$A$2:$A$14
Z8:Z9List='Date Criteria'!$A$2:$A$14
Z18List='Date Criteria'!$A$2:$A$14



Thank you for your help.
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
I think your formula has a syntax error in the last argument - should it be the following:

=COUNTIFS(Active!W3:W35,"3",Active!Z3:Z35,"6/1/2021",Active!AB3:AB35,">6/1/2021")
 
Upvote 0
Here is another approach you could use. Note that my dates are d/m/y format.

21 02 23.xlsm
WXYZAAABACADAEAF
1
231/06/20211
31
42Cat 11/05/2021
51
61
71
82Cat 11/07/2021
93Cat 21/06/2021Cat 11/07/2021
101
111
121
131
141
151
161
171
183Cat 21/07/2021Cat 11/07/2021
191
201
211
221
232Cat 11/05/2021
242Cat 11/08/2021
253Cat 21/08/2021Cat 11/08/2021
261
272Cat 11/05/2021
281
292Cat 11/07/2021
303Cat 21/04/2021Cat 11/06/2021
311
321
332Cat 11/04/2021
341
350
36
Count
Cell Formulas
RangeFormula
AF2AF2=COUNT(FILTER(W3:W35,(W3:W35=AD2)*(Z3:Z35=AE2)*(AB3:AB35>AE2),""))
 
Upvote 0
As far as I can tell your formula should work. How did you source your data ? Is there any chance it from somewhere using a different regional setting ?
If you type =month("6/1/2021") and =month(Z9) to they both return 6 ?
Do your dates have time as part of the date that is hidden by the formatting eg does =value(Z9) return a whole number or does it have a decimal component ?
 
Upvote 0
As far as I can tell your formula should work. How did you source your data ? Is there any chance it from somewhere using a different regional setting ?
If you type =month("6/1/2021") and =month(Z9) to they both return 6 ?
Do your dates have time as part of the date that is hidden by the formatting eg does =value(Z9) return a whole number or does it have a decimal component ?
The dates are entered via a dropdown list created using validation. On the tab where the values for the dates exist, they are formatted as general. I changed them to text, and then chose the same date again and am still getting the same result. Both "=month..." versions above return 6. The dates do not have time hidden by formatting and were entered as "1/1/2021", "2/1/2021" etc. to create the dropdown list.
 
Upvote 0
I
I think your formula has a syntax error in the last argument - should it be the following:

=COUNTIFS(Active!W3:W35,"3",Active!Z3:Z35,"6/1/2021",Active!AB3:AB35,">6/1/2021")
I initially had the argument set up that way and got the same result.

The odd thing is, if I remove the last part of the expression ",Active!AB3:AB35,">6/1/2021")" I get the expected result. I'm doing something wrong in the last portion.
 
Upvote 0
The dates are entered via a dropdown list created using validation. On the tab where the values for the dates exist, they are formatted as general. I changed them to text, and then chose the same date again and am still getting the same result. Both "=month..." versions above return 6. The dates do not have time hidden by formatting and were entered as "1/1/2021", "2/1/2021" etc. to create the dropdown list.
I only mentioned Z9 and your reply to denzo36 narrows the problem down to column AB.
You definitely do not want the column formatted as text prior to inputting the data. In fact if =istext(AB9) returns TRUE that will be your problem.
 
Upvote 0
I only mentioned Z9 and your reply to denzo36 narrows the problem down to column AB.
You definitely do not want the column formatted as text prior to inputting the data. In fact if =istext(AB9) returns TRUE that will be your problem.
Both Z9 and AB9 return TRUE. but when I highlight the cells, the number format shows "Date."
 
Upvote 0
I only mentioned Z9 and your reply to denzo36 narrows the problem down to column AB.
You definitely do not want the column formatted as text prior to inputting the data. In fact if =istext(AB9) returns TRUE that will be your problem.
After some more research, I noticed there is a single quote displayed in front of the date in the formula bar. If I remove the single quote the formula works. The challenge now is even if I modify the dates accordingly on the tab with the dates for the dropdown list, I still have to "redo" all the dates on the spreadsheet. Sheesh.
 
Upvote 0
After some more research, I noticed there is a single quote displayed in front of the date in the formula bar. If I remove the single quote the formula works. The challenge now is even if I modify the dates accordingly on the tab with the dates for the dropdown list, I still have to "redo" all the dates on the spreadsheet. Sheesh.
You don't need to do this manually. There are a number of ways to convert your text to numbers (which is how excel sees dates).
If you have nothing else in the column: select the whole column > Data > Text to columns > Delimited > Make sure only TAB is selected > Finish. Excel will effectively re-enter all your dates and in doing so convert them to a number/date.
If you have other things in the column select the specific cells you need to convert and follow the same steps, it should default the 1st cell as the destination and this should be fine.

You can also do it using paste special multiply (and have 1 in a cell that you use to copy before invoking the paste special)
 
Upvote 0

Forum statistics

Threads
1,214,793
Messages
6,121,617
Members
449,039
Latest member
Mbone Mathonsi

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