Solved

How do I calculate average based on a dynamic date

Posted on 2011-09-05
3
174 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 31

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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Improved? Move/Copy Add-in Replacement - How to avoid the annoying, “A formula or sheet you want to move or copy contains the name XXX, which already exists on the destination worksheet.” David Miller (dlmille)  It was one of those days… I wa…
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …
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.

707 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now