Forum Discussion
DateAdd and DatesMTD not working
- 5 years ago
Hi,
To write a measure that will return MTD sales for completed days in the month vs the same amount of days in the previous month, you do not need to create another Date table. Assuming you already have a Calendar table which only goes till the data till which there is sale, write these measures.
Total sales = sum(data[sale])
Total sales in same period last month = if(max(calendar[date])<eomonth(max(calendar[date]),0),calculate([total sales],datesbetween(calendar[date],edate(min(calendar[date]),-1),edate(max(calendar[date]),-1))),calculate([total sales],previousmonth(calendar[date])))
To your visual/filters/slicers, drag date and other other date field (month/year) from the Calendar Table.
Thanks Ashish.
Any idea why the DateADD (DATESMTD(Date[Date]),-1,MONTH) isn't working as expected? Seems like a bug?
You are welcome. I do not use the DATEADD() function. Did my solution work?