title: Calculated Column with Current Row Values and Previous Dates in Power BI (DAX)
body: <p>I'm trying to get a calculated column (not a measure) that gets the sum of a column based on the values in the current row of that table for dates that are 1 month lagged to the date on the current row.  My table has dates that are the 1st day of every month only .. no other days in the month.  I'm asking the question about DAX; however, I have no problem implementing in M Language in Power Query (actually would probably prefer) if there is a solution that way as well.   </p>
  
  <p>I have been able to get a measure to work using something like this.. </p>
  
  <pre><code>CALCULATE(SUM(AMT), DATEADD(DATECOLUMN, -1, MONTH))
  </code></pre>
  
  <p>But I'd like to be a new column instead.</p>
  
  <p>Assuming the table looks something like this.. </p>
  
  <pre><code>A    B        C          D     AMT
  6    BAC456   5/1/2019   TEST  25
  2    EPS123   4/1/2019   TEST  45
  2    EPS123   3/1/2019   TEST  65
  6    BAC456   4/1/2019   TEST  43
  6    BAC456   4/1/2019   TEST  88
  7    GRE123   4/1/2019   TEST  90
  9    BAC456   4/1/2019   TEST  43
  </code></pre>
  
  <p>I'd like to have another column in this table where the first row would be:</p>
  
  <pre><code>A    B         C          D      AMT   NEWCOL
  6    BAC456    5/1/2019   TEST   25    131
  </code></pre>
  
  <p>Second row would be:</p>
  
  <pre><code>A    B         C          D      AMT   NEWCOL
  2    EPS123    4/1/2019   TEST   45    65
  </code></pre>
  
  <p>etc..</p>
  
  <p>In cases where the month column is the first month in the entire table NEWCOL would be 0</p>