title: Time Lookback Calculation
body: <p>I have two columns:</p>
  
  <p>Column A:  Time (seconds from midnight)</p>
  
  <p>Column B:  Value (arbitrary value I've created)</p>
  
  <p>How would I find the average value (column B) at any instance in time(row) looking back over the previous x seconds (column A)?</p>
  
  <p>Lets assume A1 = Seconds after midnight </p>
  
  <pre><code>Seconds after midnight    Value
          0                  27
          2                  29
          6                   2
         16                  29
         20                  19
         24                   4
         34                   2
         40                   1
         44                   4
         54                  12
         64                  12
         71                   3
         81                  30
         91                  21
         92                   1
         93                  27
         97                  12
        104                  30
        112                  25
  </code></pre>
  
  <p>Note that time deltas are variable so I can't just look at the last x rows.</p>
  
  <p>A specific question would be:</p>
  
  <p>In a new column (column C) return the average Value of the last 10 seconds of data.</p>
  
  <p>I have no idea how to do this.  Can anyone help?  It'd be greatly appreciated.</p>
  
  <p>EDIT:</p>
  
  <p>The output in the first 4 rows of column C would be:</p>
  
  <pre><code>Seconds after midnight    Value     Result
          0                  27              No values prior to this one
          2                  29         27   Average(B2) 
          6                   2         28   Average(B2:B3)
         16                  29          2   Average(B4)
  </code></pre>
  
  <p>For each row, I'm taking the current time (16 in the last case)...going back x seconds (10 seconds in this case) and then averaging the values from all the cells in that time range (not including the current value).</p>
  
  <p>My main issue is the time calculation.  I don't know how to calculate it as I roll forward in time and I continue to get more instances as we move forward.  If we go 10 seconds without any new data point then there would be no output since.  If we got one instance in the previous 10 seconds then the output would be that value.  If we got 100 instances in the previous 10 seconds, I need to return the average of that 100 instances.</p>
  
  <p>Again, I'd appreciate any help, hints, links.  This is driving me crazy.</p>