Average time between dates *But ignore if blank in either cell

DaveMacdonald

Board Regular
Joined
Nov 28, 2013
Messages
52
Office Version
  1. 365
Platform
  1. Windows
Version: Excel Online

I want an average of the time (in days) between two milestones for many different people (one person per row), but I want the formula to ignore that row if there isn't a date in BOTH date cells, since it throws off the average in a major way.

Example "TABLE_1"
EE NameMILESTONE 1MILESTONE 2
Dave4/12/225/12/22
Steve6/1/226/5/22
Bill7/22/227/26/22
Frank8/1/22

Current Formula =SUMPRODUCT(TABLE_1[MILESTONE 2]-TABLE_1[MILESTONE 1])/COUNT(TABLE_1[MILESTONE 2])&" Days"

As long as both milestone 1 and 2 are populated, the formula works great, but if milestone 1 is populated and milestone 2 isn't, then it throws the whole thing off. How would I write a formula where if row 5 as above has a blank, then neither columns 2 or 3 for that row are part of the average calculation?
 
Last edited:

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
Try:

Book1
ABCDE
1EE NameMILESTONE 1MILESTONE 2
2Dave4/12/20225/12/202212.66667
3Steve6/1/20226/5/2022
4Bill7/22/20227/26/2022
5Frank8/1/2022
6
Table 1
Cell Formulas
RangeFormula
E2E2=LET(a,FILTER(B2:C7,(B2:B7<>"")*(C2:C7<>"")),SUM(a*{-1,1})/ROWS(a))
 
Upvote 0
I just noticed you're using table nomenclature. Try:

Excel Formula:
=LET(a,Table_1[[MILESTONE 1]:[MILESTONE 2]],f,FILTER(a,MMULT(--(a<>""),{1;1})=2),TEXT(SUM(f*{-1,1})/ROWS(f),"0.00"))&" days"
 
Upvote 0
I just noticed you're using table nomenclature. Try:

Excel Formula:
=LET(a,Table_1[[MILESTONE 1]:[MILESTONE 2]],f,FILTER(a,MMULT(--(a<>""),{1;1})=2),TEXT(SUM(f*{-1,1})/ROWS(f),"0.00"))&" days"
Thanks for your reply! Unfortunately I get a #VALUE! error. It is probably pertinent to the formula, Milestones 1 and 2 are not side by side, So i dont think milestone 1:milestone 2 will work. Is there a workaround for that?
 
Upvote 0
I wondered about that, I should have mentioned it. The easiest fix I can think of is to add another filter. For example:

Book1
ABCDEFG
1EE NameMILESTONE 1SomethingSomething ElseMILESTONE 2
2Dave4/12/2022aa5/12/202212.67 days
3Steve6/1/2022b6/5/2022
4Bill7/22/2022c7/26/2022
5Frank8/1/2022d
Table 1
Cell Formulas
RangeFormula
G2G2=LET(a,FILTER(Table_1[[MILESTONE 1]:[MILESTONE 2]],{1,0,0,1}),f,FILTER(a,MMULT(--(a<>""),{1;1})=2),TEXT(SUM(f*{-1,1})/ROWS(f),"0.00"))&" days"


Look for the {1,0,0,1} array near the start of the formula. This says that there are 2 columns (the zeros) between the milestone columns. Once those are filtered out, the rest works ok.
 
Upvote 0
Solution
I wondered about that, I should have mentioned it. The easiest fix I can think of is to add another filter. For example:

Book1
ABCDEFG
1EE NameMILESTONE 1SomethingSomething ElseMILESTONE 2
2Dave4/12/2022aa5/12/202212.67 days
3Steve6/1/2022b6/5/2022
4Bill7/22/2022c7/26/2022
5Frank8/1/2022d
Table 1
Cell Formulas
RangeFormula
G2G2=LET(a,FILTER(Table_1[[MILESTONE 1]:[MILESTONE 2]],{1,0,0,1}),f,FILTER(a,MMULT(--(a<>""),{1;1})=2),TEXT(SUM(f*{-1,1})/ROWS(f),"0.00"))&" days"


Look for the {1,0,0,1} array near the start of the formula. This says that there are 2 columns (the zeros) between the milestone columns. Once those are filtered out, the rest works ok.
You're clearly a wizard because that worked like magic! (too corny?) Really though that's it exactly, thank you so much!
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,337
Members
452,637
Latest member
Ezio2866

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