View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Maistrye Maistrye is offline
external usenet poster
 
Posts: 1
Default Calculate a 30-day moving average based on the last x number of entries and date


Someone will probably have something better. However, here is a
possibility in the meantime.

I'm assuming Row 1 has your titles and Column A refers to your Column 1
and Column B to Column 2.

I'd put the following function in Column C: (Find the last date with a
value)
=A2 (For Cell C2)
=IF(B3<0,A3,C2) (For the rest)

I'd put the following function in Column D:
=(SUMIF($A$2:A2,"<="&C2,$B$2:B2)-SUMIF($A$2:A2,"<"&C2-29,$B$2:B2)) /
(COUNTIF($A$2:A2,"<="&C2)-COUNTIF($A$2:A2,"<"&C2-29))

If this isn't what you meant, you'll have to explain some more.

Scott

gimiv Wrote:
Hello, I have a worksheet that has all weekday dates in column 1 and
values in column 2. I want to create a 30-day moving average based on
the last (non-zero) value in the column 2. Since every month has a
different amount of days, I want it to search the date that has the
last value (since I don't get a chance to update it daily) and go back
thirsty days from that date and give an average of all the column 2
values skipping and values that are null or zero.

Any ideas?

Thanks,

Gimi



--
Maistrye
------------------------------------------------------------------------
Maistrye's Profile: http://www.excelforum.com/member.php...o&userid=36078
View this thread: http://www.excelforum.com/showthread...hreadid=558670