Calculating average based on different amounts of blank cells

Elrond

New Member
Joined
Sep 19, 2016
Messages
3
Hello,
I have a table of moths captured in a trap every few days.
I want to make a chart that would show me the daily average.
Note that the amount of days between each capture varies.
See the example table below, I am looking for a formula that could give me the the third column ("average moths per day").

Any ideas?

Thanks a lot!
E.

datemoths in trapaverage moths per day
15/08/201611
16/08/201610
17/08/201610
18/08/201610
19/08/20164010
20/08/201620
21/08/201620
22/08/20166020
23/08/20164
24/08/20164
25/08/20164
26/08/20164
27/08/2016204

<tbody>
</tbody>
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
I came up with something but have not tested thoroughly. It does seem to work with your example. Assuming your Date is in Column A and your trapped moths is in column B, add the following array formula in Column C:

=IF(B2>0,B2/(ROW(B2)-MAX(IF($B$1:B1>0,ROW($B$1:B1)),0)),C3)

Confirm with CTRL+Shift+Enter (this will add curly braces at the beginning and end of the formula) and apply below
 
Upvote 0
Thank you Simon,
It seems to work. The only problem is when trapped moths are 0.
In the example below the 15/8 sholdn't be counted, so that the 8 should be a 10.

datemoths in trapaverage moths per day - formula
15/08/201608
16/08/20168
17/08/20168
18/08/20168
19/08/2016408
20/08/201620
21/08/201620
22/08/20166020
23/08/20164
24/08/20164
25/08/20164
26/08/20164
27/08/2016204

<tbody>
</tbody>
 
Upvote 0
Try this in C2:

=IF(AND(ISNUMBER(B2),B2=0),0,IF(ROW(B2)=2,B2,IF(B2<>0,B2/(ROW(B2)-MAX(IF(ISNUMBER($B$1:B1),IF($B$1:B1>=0,ROW($B$1:B1)),0))),C3)))

Confirm with CTRL+Shift+Enter
 
Upvote 0

Forum statistics

Threads
1,215,444
Messages
6,124,891
Members
449,194
Latest member
JayEggleton

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