title: How to I calculate the sum of the last 7 rows, for each row, inside an ArrayFormula?
body: <p>I have a column D with numerical values and on an adjacent column, I want to display the sum for the last 7 rows relative to the current row.  </p>
  
  <p>I've tried a couple of variants, most of them inspired by StackOverflow and other sites but they haven't worked as I need them.</p>
  
  <p>I figured that since Offset() creates a range it would be simple to just "slice" the range I need and feed it to sum()</p>
  
  <p><code>ArrayFormula( Sum(Offset(D7:D500,-6,1,7,1)) )</code></p>
  
  <p>However, it seems that it only calculates the cell I place this formula in.</p>
  
  <p>I adapted a potential solution I found online to my situation </p>
  
  <p><code>ArrayFormula(SUMIF(ROW(D7:D500),"&lt;="&amp;ROW(D7:D500),D7:D500))</code></p>
  
  <p>This one calculates the sum for all the previous rows, 
  so I figured using SUMIFS() would get me what I need, therefore </p>
  
  <p><code>=ArrayFormula(SUMIFS(D7:D500, ROW(D7:D500),"&lt;="&amp;ROW(D7:D500), ROW(D7:D500),"&gt;"&amp;ROW(D7:D500)-7))</code></p>
  
  <p>But this one just doesn't work. 
  I've also tried creating the range with Address() and Interpret() but it seems they don't work properly inside ArrayFormula()</p>
  
  <p>I'm fairly new at it so it might just be that I'm not using them properly. What am I doing wrong here?  Is there a better way of doing this? I would rather use ArrayFormula() if possible since the formula will live in a single cell.</p>