# Countifs formula based on multiple criteria and a date less than today

#### jme_4477

##### New Member
Hello again,

I do have one more question for you....In this formula:
=IFERROR(IF(OR(INDEX(Sheet2!\$K\$2:\$K\$138,MATCH(B2,Sheet2!\$C\$2:\$C\$138,0))="",-7),1,0),0)

How do I have it calculate ONLY if the cell in Sheet 2 column K is blank and it's been more than 7 days? So once a date is entered in column K (even if it's after 7 days) it no longer will total?

### Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number

#### jasonb75

##### Well-known Member
Not sure if I'm reading the information correctly, see if this does it.

=IFERROR(IF((INDEX(Sheet2!\$K\$2:\$K\$138,MATCH(B2,Sheet2!\$C\$2:\$C\$138,0))-TODAY())<7,1,0),0)

As you said 'Sheet 2 column K is blank' I've assumed formulas that show a blank using "". If column K is empty then the results will most likely be wrong.

#### jme_4477

##### New Member
Thank you for your help. That didn't work though It actually counted everyone.

What I'm looking for is a formula that only calculates the more than 7 days until there is a date entered.

So if we are on the Enrollment tab, look at column G, this column should only count a total if no date appears in So the formula is looking at Sheet 2, Column G:

=IFERROR(IF(OR(INDEX(Sheet2!\$J\$2:\$J\$18,MATCH(B2,Sheet2!\$C\$2:\$C\$18,0))="",INDEX(Sheet2!\$J\$2:\$J\$18,MATCH(B2,Sheet2!\$C\$2:\$C\$18,0))-7 > A2),1,0),0)

It’s comparing the date in Enrollment tab, Column A to Sheet 2, Column J. It’s looking to see if there’s a date past 7 days in there. What I need, though, is it only to look if there’s a date past 7 days if 1) in Sheet 2 there’s an ID number in Column C, 2) there’s nothing entered in Sheet 2, Column J, and 3) if it’s been longer than 7 days based on the date in Enrollment tab, Column A.

I can probably modify the other formulas in the Enrollment tabs J and M once I know how to do this, but for everything, I need it not to calculate any longer once a date is entered.

Does this help?

Thank you again!!!

#### jasonb75

##### Well-known Member
There's something in there that is just not clicking into place with me, it would be easier to follow if you could upload another sample file, perhaps highlight the entries that should be counted, that should make it a bit clearer.

#### jme_4477

##### New Member
Yes, I sure can Thank you again for your help. I added comments directly into the Excel sheet with my questions. It's on the Enrollment tab. Here's the link:
https://1drv.ms/x/s!Aigq1WyI8ss7go82xDpY6vBDPSUiyg

#### jasonb75

##### Well-known Member
For some silly reason the proverbial penny is still not dropping, looking at the enrolment tab it looks like the formulas that you already have are giving you the results that you're asking for.

The 2 records that your notes say are blank in column J of sheet 2 are not blank, however they are blank in column K which could be leading to some confusion.

#### jme_4477

##### New Member
Oh my goodness....It's not the proverbial penny....It's me I think I got myself confused. Can you take another look at the doc? I think I've figured out how to word it. So sorry!!!

#### jasonb75

##### Well-known Member
I'm still confused, with the date missing in sheet 2, there is nothing to compare to the date in column A to establish if it is more than 7 days.

I thought that you might want 7 days from the current date, but the examples are only 4 days and 2 days?