Calculating average times in expandable table

JenniferMurphy

Well-known Member
Joined
Jul 23, 2011
Messages
2,531
Office Version
  1. 365
Platform
  1. Windows
I have a table with three sets of timestamps when some activity took place. I want to calculate the average of the time portion of the timestamps. I was able to get an array formula using the MOD function to work:

C/RDEF
6Sample ASample BSample C
703/01/19 09:07:4403/01/19 08:22:1403/01/19 09:22:25
803/02/19 08:41:1303/02/19 07:55:5203/02/19 09:16:33
903/04/19 09:10:2903/04/19 08:33:0203/04/19 09:09:34
1003/06/19 08:55:0003/06/19 08:11:2603/06/19 08:55:58
1103/07/19 09:12:0403/07/19 07:51:5603/07/19 09:29:34
129:01a8:10a9:14a

<tbody>
</tbody>

The formula in D12 is
Code:
{=AVERAGE(MOD(OFFSET(F6,1,0):OFFSET(F12,-1,0),1))}

The problem arises if there is missing data. The AVERAGE function will ignore empty cells, but the MOD function turns an empty cell into a zero, messing up the average.

C/RDEF
6Sample ASample BSample C
703/01/19 09:07:4403/01/19 08:22:1403/01/19 09:22:25
803/02/19 08:41:1303/02/19 07:55:5203/02/19 09:16:33
903/04/19 09:10:2903/04/19 09:09:34
1003/06/19 08:55:0003/06/19 08:11:2603/06/19 08:55:58
1103/07/19 09:12:0403/07/19 07:51:5603/07/19 09:29:34
129:01a6:28a9:14a

<tbody>
</tbody>

I tried putting a text string in that cell ('n/a or '--), but that gets a value error. Is there a way to get this work calculate the correct average of the non-empty cells?
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Hello,

If I understand correctly in cell D2 ... the formula works out the Average for Column F ... (which can be disturbing ...)

But the issue remains to avoid blank cells ...

You could test following:

Code:
=SUM(MOD(OFFSET(F6,1,0):OFFSET(F12,-1,0),1))/(COUNTA(OFFSET(F6,1,0):OFFSET(F12,-1,0)))

Hope this will help
 
Upvote 0
Hello,

If I understand correctly in cell D2 ... the formula works out the Average for Column F ... (which can be disturbing ...)
Doh! :oops: I meant to say that formula was in F12, no D12. Sorry about that. :oops:

But the issue remains to avoid blank cells ...

You could test following:

Code:
=SUM(MOD(OFFSET(F6,1,0):OFFSET(F12,-1,0),1))/(COUNTA(OFFSET(F6,1,0):OFFSET(F12,-1,0)))

Hope this will help
Brilliant. It works perfectly, provided that I make it an array formula:
Code:
{=SUM(MOD(OFFSET(F6,1,0):OFFSET(F12,-1,0),1))/(COUNTA(OFFSET(F6,1,0):OFFSET(F12,-1,0)))}

Thank you! (y)
 
Upvote 0
Glad you could fix your problem ...:wink:

Thanks a lot for the Beer ... !!! :)
 
Upvote 0

Forum statistics

Threads
1,214,784
Messages
6,121,535
Members
449,037
Latest member
tmmotairi

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