title: Google Sheets - ArrayFormula Calculate Difference with Previous Cells
body: <p>Using a Google Spreadsheet, I am wanting to be able to put a formula into the header column so that I don't have to manually fill rows (I have a Google Script which is adding values automatically each day). I understand that a common way to do this is using ArrayFormula.</p>
  
  <p>I have a few formulas which I want to setup like this, but for now I'm trying to get a difference between the current cell and the previous row's cell going.</p>
  
  <p>This is what it should be doing:</p>
  
  <p><code>Bal  Dif
  0
  20   20
  20   0
  21   1
  22   1</code></p>
  
  <p>The closest I can get with an ArrayFormula is this though:</p>
  
  <p><code>Bal  Dif
  0    20
  20   0
  20   1
  21   1
  22   1</code></p>
  
  <p>This is using the formula: <code>=arrayformula(D2:D-D1:D)</code>.
  Its almost as if I need <code>=arrayformula(D1:D-D0:D)</code> but obviously this isn't valid.</p>
  
  <p>Any nice ways to get the difference value on the line which actually has the new value?</p>
  
  <p>Thanks, hope someone can help.</p>