30, 60 or 90 day averages

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How can I create a function to return a 30, 60, 90 date average based on a
date field. In other words, if date of a row is within the past month,
include it in the avg calculation. Thanks,

-BP-
 
Bendleton said:
How can I create a function to return a 30, 60, 90 date average based on a
date field. In other words, if date of a row is within the past month,
include it in the avg calculation. Thanks,

-BP-

Hello,

If A1 holds your comparison date (i.e. TODAY()), column B your date
data and column C your data you like to average, then

=SUMPRODUCT(--(B1:B99-A1>=0),--(B1:B99-A1<30),C1:C99)/SUMPRODUCT(--(B1:B99-A1>=0),--(B1:B99-A1<30))

This is for 30 days rolling. If you need a special month, for example
December 2006 (enter any day of Dec 2006 into A1):
=SUMPRODUCT(--(YEAR(B1:B99)=YEAR(A1)),--(MONTH(B1:B99)=MONTH(A1)),C1:C99)/SUMPRODUCT(--(YEAR(B1:B99)=YEAR(A1)),--(MONTH(B1:B99)=MONTH(A1)))

For two or three months I would add two or three of these formulas.
Just take DATE(YEAR(A1),MONTH(A1)-1,1) instead of A1 for the month
before and DATE(YEAR(A1),MONTH(A1)-2,1) instead of A1 for two months
before A1.

Regards,
Volker
 
Hi

One way would be with an array formula.
With dates in column A, values to be averaged in B, place the required
number of days (30 or 60 or 90) in C1
{=AVERAGE(IF(TODAY()-A1:A10<C1,B1:B10))}

Array formulae must be committed or Edited with Control+Shift+Enter
(CSE) not just Enter.
Using CSE, Excel will insert the curly braces { } around the
formula, do not type them yourself.
Change ranges to suit.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top