Google Answers Logo
View Question
 
Q: moving average in Excel ( No Answer,   6 Comments )
Question  
Subject: moving average in Excel
Category: Computers > Software
Asked by: placain-ga
List Price: $8.00
Posted: 14 Jun 2004 12:46 PDT
Expires: 17 Jun 2004 10:30 PDT
Question ID: 360980
I have a spreadsheet with data like this:
Date, Time, Value
2004/05/28, 13:22:03, 3
2004/05/28, 18:20:42, 6
2004/06/02, 05:42:10, 5
2004/06/05, 10:10:30, 5
etc etc.

I would like to add two additional columns. The first column should
contain a 5 day moving average of number of data rows per day - that
is, if each data row represents an event, how many events happened PER
DAY in the last 5 days?

The second column should contain a 5 day moving average of VALUE -
that is, what is the average of VALUE over the last 5 days?

Note that there is no regularity to the frequency of data rows - the
only thing that is guaranteed is that they're in chronological
ascending order. There might be several rows in one day, and then no
rows for several days, etc.
Answer  
There is no answer at this time.

Comments  
Subject: Re: moving average in Excel
From: peely-ga on 15 Jun 2004 06:35 PDT
 
assuming that the first date is in cell A2, the formula in E2 would be
=countif(A$2:A2,">" & A2-5). The formula in F2 would be 
=AVERAGE(OFFSET(E2,1-D2,-2,D2,1). Autofill the formulas down the
sheet.
;)
Subject: Re: moving average in Excel
From: peely-ga on 15 Jun 2004 06:41 PDT
 
OOps!
assuming that the first date is in cell A2, the formula in D2 would be
=countif(A$2:A2,">" & A2-5). The formula in E2 would be 
=AVERAGE(OFFSET(E2,1-D2,-2,D2,1). Autofill the formulas down the
sheet.
Subject: Re: moving average in Excel
From: placain-ga on 16 Jun 2004 08:29 PDT
 
peely, can you explain to me exactly what that is doing? I'm a real excel novice...
Subject: Re: moving average in Excel
From: peely-ga on 16 Jun 2004 21:10 PDT
 
you don't want much do you! I'm not a researcher so this one's for
free. If the date is in cell A2, the first formula subtracts 5 days
from the date A2-5. Countif counts how many instances of this value
(greater than 5 days ago) happened in the range A$2:A2. This is one
cell at the moment. When you double click the little cross at the
bottom right of the cell the formula is copied to all the cells bellow
to the last cell of the current region. If the sheet is 40 rows long,
the last formula would look like this: =countif(A$2:A40,">" & A40-5).
The dollar symbol "fixes" a reference when pasting or using autofill
so A$2 stays the same and the range the formula is counting in is
extended up to the last one on thge sheet.
The second formula uses the value in the first formula (in cell D2) to
determine the size and position of the range with dates greater than
five days ago. This of course will be 1 in the first cell of the sheet
as there is only one cell. Offset looks up a range of cells which is
like this =Offset(Cell to lookup, horizontal offset, vertical offset,
cells high, cells wide), so it will average the contents of a range
which begins a counted number of cells higher "1-d2" than the current
cell "E2" , two cells to the left "-2", the counted number of cells
high "d2", and one cell wide)
Subject: Re: moving average in Excel
From: peely-ga on 16 Jun 2004 21:24 PDT
 
All excel users, novices and experts would benefit from the free
tutorials and resources available from
http://spreadsheets.about.com/od/excel101thebasics/. Advanced data
miners check http://www.cpearson.com out.
Subject: Re: moving average in Excel
From: placain-ga on 17 Jun 2004 10:29 PDT
 
Wow! Thanks so much! Wonderful! I will close this question now, since
you've answered it ... I hope you get made a researcher soon peely...

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy