Solved

How do I calculate average based on a dynamic date

Posted on 2011-09-05
3
177 Views
Last Modified: 2012-05-12
I have a spreadsheet with the following layout.

       06/06/2011      13/06/2011      20/06/2011      27/06/2011      04/07/2011      11/07/2011
Line 1      114      200      980      879      675      600
Line 2      78      50      333      89      32      23
Total      2281      2294      2147      1906      2254      2043

On a new worksheet I want to be able to calculate the past 4 weeks average for each line,
 based on the date the user enters.

Eg if I enter 11/07/2011 in the below cell I want the average to be calculated for Line 1 and Line 2.

11/07/2011
Line 1      (fomula here to calc avg of 04/07/2011 to 13/06/2011)
Line 2      (fomula here to calc avg of 04/07/2011 to 13/06/2011)
0
Comment
Question by:JAK11
3 Comments
 
LVL 50

Accepted Solution

by:
barry houdini earned 250 total points
ID: 36486175
You can use AVERAGEIFS function, something like this

=AVERAGEIFS(Data!A2:Z2,Data!A$1:Z$1,">="&D$2-28,Data!A$1:Z$1,"<="&D$2-7)

where D2 is your date and in Data sheet row 1 has the dates and row 2 has your "Line 1" data. Repeat for line 2 (just drag formula down a line)

regards, barry
0
 
LVL 32

Expert Comment

by:Rob Henson
ID: 36487893
Or you could use OFFSET to create the range to be averaged.

=AVERAGE(OFFSET(Ref,RowOffset,ColOffset,Height,Width))

Ref - first column of particular row
Rowoffset - Current row so 0
Coloffset - use Match to find column with date and less 3 for 4 weeks earlier.
Height - only one row so 1
Width - 4 weeks so 4

Thanks
Rob H
0
 

Author Comment

by:JAK11
ID: 36495409
This is great thanks.

If there are no data in the week columns how do i tell it to average the weeks with the data in. For eg if 11/07/11 didn't contain data i would want to take the 4 weeks average from the cells which do contain the data so this would take average 4 prev average from 04/07/11.
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Multiple Open Excel Spreadsheets 12 41
remove dups 10 37
VBA copy column paste as value 5 21
Excel - conditional formatting on several columns 9 36
Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question