Average number of days, with missing data

petersw

New Member
Joined
Sep 22, 2011
Messages
10
Hi,

I've got two columns of dates, and want to find the average number of days between them. Column A is the start date, and Column B is the end date. However, some start dates are missing and marked as "UNK":

Column A | Column B
1/1/2010 | 3/4/2010
2/1/2010 | 5/19/2010
UNK | 4/1/2010


If no dates were missing, I'd use =SUM(INDEX(B1:B3-A1:A3,0,1))/COUNT(A1:A3). However, I'm not sure how to skip lines that have "UNK" in Column A. As I found out, SUMIF doesn't seem to work with an Index statement.

This seems like it should be fairly easy...but not for me! Thanks in advance...
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Hi,

I've got two columns of dates, and want to find the average number of days between them. Column A is the start date, and Column B is the end date. However, some start dates are missing and marked as "UNK":

Column A | Column B
1/1/2010 | 3/4/2010
2/1/2010 | 5/19/2010
UNK | 4/1/2010


If no dates were missing, I'd use =SUM(INDEX(B1:B3-A1:A3,0,1))/COUNT(A1:A3). However, I'm not sure how to skip lines that have "UNK" in Column A. As I found out, SUMIF doesn't seem to work with an Index statement.

This seems like it should be fairly easy...but not for me! Thanks in advance...
Try this array formula**:

=AVERAGE(IF(ISNUMBER(B2:B4-A2:A4),B2:B4-A2:A4))

** array formulas need to be entered using the key
combination of CTRL,SHIFT,ENTER (not just ENTER).
Hold down both the CTRL key and the SHIFT key
then hit ENTER.
 
Upvote 0
You could use an array formula like this

=AVERAGE(IF(ISNUMBER(A1:A3),B1:B3-A1:A3)))

or a non-array approach

=(SUMIF(A1:A3,"<>UNK",B1:B3)-SUMIF(A1:A3,"<>UNK"))/COUNT(A1:A3)
 
Upvote 0

Forum statistics

Threads
1,224,594
Messages
6,179,792
Members
452,942
Latest member
VijayNewtoExcel

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