Forum Discussion
Formula today -1 month
- 6 years ago
Hi Anonymous
Today is 2019/10/18, so this month is from 2019/10/1~2019/10/18, last month is from 2019/9/1~2019/9/18
Create measures
current = CALCULATE ( DISTINCTCOUNT ( Sheet1[visitor] ), FILTER ( 'date table', 'date table'[year] = YEAR ( TODAY () ) && 'date table'[month] = MONTH ( TODAY () ) && 'date table'[Date] <= TODAY () ) )today-1_month = CALCULATE ( DISTINCTCOUNT ( Sheet1[visitor] ), DATEADD ( FILTER ( DATESMTD ( 'date table'[Date] ), 'date table'[Date] <= TODAY () ), -1, MONTH ) )Best Regards
MaggieCommunity Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. - Anonymous6 years ago
Try
= Date.AddMonths(DateTime.Date(DateTime.LocalNow()),-1)
Try
= Date.AddMonths(DateTime.Date(DateTime.LocalNow()),-1)
Hi Anonymous
thank you. That is what I need. Perfect!
Do you know wether it i possible to say: Take the local now Minus 1 day and go back 1 month?
Thank you!
- Anonymous6 years agoNot applicable
Sure Kris, add the text in bold below:
Date.AddMonths(DateTime.Date(DateTime.LocalNow()+#duration(-1,0,0,0)),-1)
BTW, power query has a whole lot of date, datetime, datetimezone and duration functions that can be found at the link below.
https://docs.microsoft.com/en-us/powerquery-m/date-functions
Regards,
Mike
- Anonymous6 years agoNot applicable
That is awesome. Thanks a lot Anonymous
Yeah, I found that document as well, but everything I did resulted in errors :-)