lookup last nth number of items in a list
This is very complicated.
Since you seem to be adding data we'll need to use dynamic ranges.
Dates = A1:An
Values to average = B1:Bn
Create these named formulas...(use the appropriate sheet name)
Goto InsertNameDefine
Name: Dates
Refers to:
=Sheet2!$A$1:INDEX(Sheet2!$A:$A,COUNT(Sheet2!$B:$B ))
Name: Nums
Refers to:
=Sheet2!$B$1:INDEX(Sheet2!$B:$B,COUNT(Sheet2!$B:$B ))
Name: LastDate
Refers to:
=INDEX(Sheet2!$A:$A,COUNT(Sheet2!$B:$B))
Name: LastNum
Refers to:
=INDEX(Sheet2!$B:$B,COUNT(Sheet2!$B:$B))
D1 = number of instances you want to average
DOW = a number from 1 to 7 for the day of the week to average. 1 = Sunday
through 7 = Saturday
Note: there is no error checking in this formula. If there aren't n
instances to average you'll get an error.
Array entered** :
=AVERAGE(IF(WEEKDAY(LastDate:INDEX(Dates,LARGE(IF( WEEKDAY(Dates)=DOW,ROW(Dates)),D1)))=DOW,LastNum:I NDEX(Nums,LARGE(IF(WEEKDAY(Dates)=DOW,ROW(Dates)), D1))))
** array formulas need to be entered using the key combination of
CTRL,SHIFT,ENTER (not just ENTER). Hold down both the CTRL key and the SHIFT
key then hit ENTER.
--
Biff
Microsoft Excel MVP
"D. Stacy" .(remove_this_part). wrote in message
...
I have list of date series data that updates every day (thus growing data
array); What I want is a formula that will me to constantly evualate the
n
number of records. For example compute the average of the last 26
Monday's
from a data listing; the data is general date ordered but that is not a
given.
Date DOW Value
1/2/09 2 37
.....
Any ideas?
|