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 again for your help. Any idea how to do Quarter To Date vs same time last quarter?
You are welcome. Try the STARTOFQUARTER() and ENDOFQUARTETR() DAX functions.