COUNTIFS with dates smaller than a date in other cell

virtuosok

Board Regular
Joined
Sep 2, 2020
Messages
209
Office Version
  1. 365
Platform
  1. Windows
Hi,
Appreciate your help with the following formula which is not working as I would want:
Excel Formula:
=COUNTIFS('Source'!$E$13:$E$15000, C2, 'Source'!$M$13:$M$15000, "<Z2")
Essentially, I would need to count only those dates in column M which are smaller than the date noted in cell Z2
I have the following issues:
1. Z2 is formatted as Date, format 01 Jan 2000. This cell in itself is an INDEX/MATCH output from exported source though. At the same time, column M on Source tab is formatted as Custom, 01-Jan-2020 (and is also an export from another source). Changing that would be problematic as the inputs are dynamic. I need to somehow compare the values even though the format is different, if at all possible.
2. I'll need the formula which can be pulled down across the whole column, i.e. next cell matching Z3 and so on.
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
It should be "<"&Z2 not "<Z2" otherwise it's treating Z2 as a value rather than a cell reference
 
Upvote 0
Hi Virtuosok,

I see Fluff has already advised how to make Z2 relative. I see C2 is already relative so that will increment also as you copy down.

The date formats shouldn't matter as long as they are numeric and only contain dates, not dates and times.

Is this what your sheet looks like? (I put the formula in column G).

Virtuosok.xlsx
CDEFGHMNZ
202-Feb-202005 Mar 2020
302-Feb-202006 Mar 2020
403-Feb-202007 Mar 2020
504-Feb-202008 Mar 2020
605-Feb-202009 Mar 2020
702-Feb-202009 Sep 2020
8
12
1302-Feb-2020203-Mar-2020
1402-Feb-2020204-Mar-2020
1503-Feb-2020105-Mar-2020
1604-Feb-2020106-Mar-2020
1705-Feb-2020009-Sep-2020
1802-Feb-2020304-Apr-2020
Source
Cell Formulas
RangeFormula
G13:G18G13=COUNTIFS(Source!$E$13:$E$18,C2, Source!$M$13:$M$18, "<"&Z2)
 
Upvote 0
Thank you both! The revised formula works better, but still doesn't capture everything. Let me bring 2 clips to illustrate. First one is for the actual formula in cell F4:
Capture1.PNG


The other one is the source ("Seizure diary") tab. We have multiple instances of the dates in column M which are before the date in Z4 above, yet formula returns zero.
Capture2.PNG


The entry in Z4 itself is a formula
Excel Formula:
{=INDEX('Subject summary'!$Q$2:$Q$500,MATCH(S4&T4, 'Subject summary'!$A$2:$A$500&'Subject summary'!$E$2:$E$500,0))}
 
Upvote 0
Check that you don't have any leading/trailing spaces on the ID in C4 & col E, also check that all the dates are real dates & not text.
 
Upvote 0
Thanks! No concerns about leading/trailing spaces, but the dates in column M may well be a text. Is it possible to embed DATAVALUE into the formula above or otherwise circumvent the limitation?
 
Upvote 0
You would be better of converting the dates to real dates.
 
Upvote 0
Yeah, if it were not for the dynamic inputs (data imports from third parties couple of times a week and overrides existing source), I would set up helper columns with conversion. I can still try to do that by adding another sheet, but wondering if formulas can do the trick instead.
 
Upvote 0
Try using Text to columns on column M on page 2 of the wizard uncheck all boxes & on page 3 select date & format of DMY.
 
Upvote 0
Solution

Forum statistics

Threads
1,214,991
Messages
6,122,628
Members
449,095
Latest member
bsb1122

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