Forum Discussion
Referencing previous month data in a calculated column
Hi Giotto,
Thank you for your suggestion.
Could break down (explain) what the second part of your formula is doing after 'return? My table is more complicated than the simplified example I provided and I cannot figure out how to apply your formula as I don't understand it). I tried breaking this into two steps by first creating a measure column instead of the variable that you suggested. I expected that this will give me a column with the previous month breaches (effectively shifting the 'breaches' one month up, so after that it's just comparing two columns.
My Column
Breach previous month = CALCULATE(SUM('Table'[Breach Status]),DATEADD('Table'[Date],-1,MONTH))
Code works (no error) but doesn't return any values, which makes me wonder if DATEADD works when my dates are not precisely one month apart. For example DATEADD('Table'[Date],-1,MONTH work when the first data is 01/01/2019 and the second date is 05/02/2019 (in dd/mm/yyyy format) or do they have to be 01/01/2019, 01/02/2019, 01/03/2019,etc
Hi,
Because my sample data's date is from 2019-12 to 2020-2 and there is no data in 2019-11.
So i use NOT and ISEMPTY to check whether the previous month exists.
Then i make current month data minus previous month data to show its status as 'Increase' or 'Decrease'.
Best Regards,
Giotto Zhi