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.

[TABLE="class: grid, width: 265, align: left"]
<tbody>[TR]
[TD="align: left"]date[/TD]
[TD="align: left"]moths in trap[/TD]
[TD="align: left"]average moths per day[/TD]
[/TR]
[TR]
[TD="align: right"]15/08/2016[/TD]
[TD]1[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD="align: right"]16/08/2016[/TD]
[TD][/TD]
[TD]10[/TD]
[/TR]
[TR]
[TD="align: right"]17/08/2016[/TD]
[TD][/TD]
[TD]10[/TD]
[/TR]
[TR]
[TD="align: right"]18/08/2016[/TD]
[TD][/TD]
[TD]10[/TD]
[/TR]
[TR]
[TD="align: right"]19/08/2016[/TD]
[TD]40[/TD]
[TD]10[/TD]
[/TR]
[TR]
[TD="align: right"]20/08/2016[/TD]
[TD][/TD]
[TD]20[/TD]
[/TR]
[TR]
[TD="align: right"]21/08/2016[/TD]
[TD][/TD]
[TD]20[/TD]
[/TR]
[TR]
[TD="align: right"]22/08/2016[/TD]
[TD]60[/TD]
[TD]20[/TD]
[/TR]
[TR]
[TD="align: right"]23/08/2016[/TD]
[TD][/TD]
[TD]4[/TD]
[/TR]
[TR]
[TD="align: right"]24/08/2016[/TD]
[TD][/TD]
[TD]4[/TD]
[/TR]
[TR]
[TD="align: right"]25/08/2016[/TD]
[TD][/TD]
[TD]4[/TD]
[/TR]
[TR]
[TD="align: right"]26/08/2016[/TD]
[TD][/TD]
[TD]4[/TD]
[/TR]
[TR]
[TD="align: right"]27/08/2016[/TD]
[TD]20[/TD]
[TD]4[/TD]
[/TR]
</tbody>[/TABLE]
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
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.

[TABLE="class: outer_border, width: 327, align: left"]
<tbody>[TR]
[TD="align: center"]date[/TD]
[TD="align: center"]moths in trap[/TD]
[TD="align: center"]average moths per day - formula[/TD]
[/TR]
[TR]
[TD="align: center"]15/08/2016[/TD]
[TD="align: center"]0[/TD]
[TD="align: center"]8[/TD]
[/TR]
[TR]
[TD="align: center"]16/08/2016[/TD]
[TD="align: center"][/TD]
[TD="align: center"]8[/TD]
[/TR]
[TR]
[TD="align: center"]17/08/2016[/TD]
[TD="align: center"][/TD]
[TD="align: center"]8[/TD]
[/TR]
[TR]
[TD="align: center"]18/08/2016[/TD]
[TD="align: center"][/TD]
[TD="align: center"]8[/TD]
[/TR]
[TR]
[TD="align: center"]19/08/2016[/TD]
[TD="align: center"]40[/TD]
[TD="align: center"]8[/TD]
[/TR]
[TR]
[TD="align: center"]20/08/2016[/TD]
[TD="align: center"][/TD]
[TD="align: center"]20[/TD]
[/TR]
[TR]
[TD="align: center"]21/08/2016[/TD]
[TD="align: center"][/TD]
[TD="align: center"]20[/TD]
[/TR]
[TR]
[TD="align: center"]22/08/2016[/TD]
[TD="align: center"]60[/TD]
[TD="align: center"]20[/TD]
[/TR]
[TR]
[TD="align: center"]23/08/2016[/TD]
[TD="align: center"][/TD]
[TD="align: center"]4[/TD]
[/TR]
[TR]
[TD="align: center"]24/08/2016[/TD]
[TD="align: center"][/TD]
[TD="align: center"]4[/TD]
[/TR]
[TR]
[TD="align: center"]25/08/2016[/TD]
[TD="align: center"][/TD]
[TD="align: center"]4[/TD]
[/TR]
[TR]
[TD="align: center"]26/08/2016[/TD]
[TD="align: center"][/TD]
[TD="align: center"]4[/TD]
[/TR]
[TR]
[TD="align: center"]27/08/2016[/TD]
[TD="align: center"]20[/TD]
[TD="align: center"]4[/TD]
[/TR]
</tbody>[/TABLE]
 
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,223,231
Messages
6,170,884
Members
452,364
Latest member
springate

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