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.
I have been able to get a measure to work using something like this..
CALCULATE(SUM(AMT), DATEADD(DATECOLUMN, -1, MONTH))
But I'd like to be a new column instead.
Assuming the table looks something like this..
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
I'd like to have another column in this table where the first row would be:
A B C D AMT NEWCOL
6 BAC456 5/1/2019 TEST 25 131
Second row would be:
A B C D AMT NEWCOL
2 EPS123 4/1/2019 TEST 45 65
etc..
In cases where the month column is the first month in the entire table NEWCOL would be 0