Forum Discussion
DATEADD BUG
Hello Everyone.
I have this formula here that gives me sales for the same period last month. IE: if today is June 8th it will show sales up to May 8th.
Anonymous , Try one of the two options
last MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date],-1,MONTH)))
Last MTD QTY forced=
var _max = date(year(today()),month(today())-1,day(today()))
return
CALCULATE(Sum('order'[Qty]),DATESMTD(dateadd('Date'[Date],-1,year)),'Date'[Date]<=_max)
2 Replies
- amitchandakSuper User
Anonymous , Try one of the two options
last MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date],-1,MONTH)))
Last MTD QTY forced=
var _max = date(year(today()),month(today())-1,day(today()))
return
CALCULATE(Sum('order'[Qty]),DATESMTD(dateadd('Date'[Date],-1,year)),'Date'[Date]<=_max)- AnonymousNot applicable
Thank you very much the second one worked.
Sales -1M (Same Period) =VAR MAXDATE = DATE(YEAR(today()),MONTH(TODAY())-1,DAY(TODAY()))RETURNCALCULATE([Sales],DATESMTD(DATEADD('(Dim) Calendar'[Date],-1,MONTH)),'(Dim) Calendar'[Date] <= MAXDATE)Do you know why the first formula didnt work? is it a Bug with DATEADD or TODAY, when using <=?