LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 8,520
Default lookup last nth number of items in a list

That happens with me too Biff..The first solution may not be always the best
one..and when I re-look at it (more often as you told while sleeping); will
get a better one....

If this post helps click Yes
---------------
Jacob Skaria


"T. Valko" wrote:

I do my best thinking while I'm sleeping. And, as is often the case, I
thought of a better solution while I was sleeping that uses the same logic
as you have used.

A - Find the last weekday date
B - Calculate the date backwards for n weeks
C - Get the average for the weekday from A to B

Nice and simple!

I would still use dynamic ranges and use cells to get the date range:

For the last weekday date...

F2:

=LOOKUP(2,1/(WEEKDAY(Dates)=2),Dates)

For the date n weeks backwards...

E2:

=F2-((n-1)*7)

Where n = the number of instances to average

Then, array entered** for the average:

=AVERAGE(IF((WEEKDAY(Dates)=2)*(Dates=E2)*(Dates< =F2),Nums))

** 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


"Jacob Skaria" wrote in message
...
Oops; it is average..Try the below array formula

'for last 3 mondays
=AVERAGE(IF((A1:A10000)*(WEEKDAY(A1:A1000)=2)*(A1 :A1000TODAY()-(3*7)),C1:C1000))

'Replace n with the number or cell reference
=AVERAGE(IF((A1:A10000)*(WEEKDAY(A1:A1000)=2)*(A1 :A1000TODAY()-(n*7)),C1:C1000))


If this post helps click Yes
---------------
Jacob Skaria


"Jacob Skaria" wrote:

Since your data gets updates every day you can try the below ** array **
formula. An array formula is same as normal formulas except you press
CTRL+SHIFT+ENTER to enter the formula. If successful in 'Formula Bar' you
can
notice the curly braces at both ends like "{=<formula}"

'For the last 3 mondays
=SUM(IF((A1:A10000)*(WEEKDAY(A1:A1000)=2)*(A1:A10 00TODAY()-(3*7)),C1:C1000))

OR

'replace n with a cell reference to denote the number of mondays
=SUM(IF((A1:A10000)*(WEEKDAY(A1:A1000)=2)*(A1:A10 00(TODAY)-(n*7)),C1:C1000))


If this post helps click Yes
---------------
Jacob Skaria


"D. Stacy" wrote:

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?




 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Lookup duplicate items in a list Niall Excel Worksheet Functions 5 September 6th 08 03:06 AM
Lookup formula for purchased items with same invoice number Johnds Excel Discussion (Misc queries) 5 May 9th 07 01:40 PM
Counting number of text items in list Becky Excel Discussion (Misc queries) 0 November 29th 06 09:56 PM
Need a number count of items on list after Filterings Taylor Excel Worksheet Functions 5 March 21st 06 06:32 AM
counting number of particular items in a list vikkam Excel Discussion (Misc queries) 8 July 5th 05 08:35 AM


All times are GMT +1. The time now is 09:19 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"