Tyler said:
I need to filter out only the last x number of days/hours of data from my
work sheet. The worksheet posts new data every 5 minutes. I need to extract
the newest data points. The time will vary from 7 days to 90 days.
My existing data has a date/time combination. It looks like
this,"12/19/2008 19:10"
Here's a possibility.
I set up a time series in A:A, and random values in B:B.
First determine the date of the last entry:
D2=INT(MAX(A:A))
If you don't want to roll back to midnight, eliminate the INT() portion.
Next figure out the value of the first entry that is, say, 30 days back:
E2=D2-30
Next determine where the 30-day back record is located:
F2=MATCH(E2,A:A,1)
And determine where the last record is located:
G2=COUNTA(A:A)
Lastly, create a range based on what we know:
H2=SUM(OFFSET($A$1,F2,1,G2-F2,1))
This will sum the values in the last 30-day range. If you are charting,
you can just use the OFFSET piece as a data value source:
=OFFSET($A$1,F2,1,G2-F2,1)
The corresponding x- or category value source would be:
=OFFSET($A$1,F2,0,G2-F2,1)
Of course you could do all this without the extra helper columns, but I
thought it might help to see the steps.
Hope this helps!