Solved

How do I calculate average based on a dynamic date

Posted on 2011-09-05
3
188 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 33

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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
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 create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

688 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