Forum Discussion
Previous n months removing current month
I'm filtering a date column to get today and previous 12 months since today.
For example, today is 5/8/2023, so I want all data since 5/1/2022 - 5/8/2023. I'm using the following filter option, but it's removing all days in May 2023. How do I fix this?
So then if I check this and try to get dates in this month, my table is empty. Yes, I do have data for this month.
Hi Anonymous,
Didn't notice you were working with datetime, small adjustment
Table.SelectRows( PrevStepName, each let d = Date.From( DateTime.FixedLocalNow()) in [DateTime] >= DateTime.From( Date.StartOfMonth( Date.AddYears( d, -1))) and [DateTime] <= DateTime.From( d ))
Ps. If this helps solve your query please mark this post as Solution, thanks!
3 Replies
- m_dekorteResident Rockstar
Hi Anonymous,
In the formula bar change the M code to:
Table.SelectRows( PrevStepName, each let d = Date.From( DateTime.FixedLocalNow()) in [Date] >= Date.StartOfMonth( Date.AddYears( d, -1)) and [Date] <= d )
Ps. If this helps solve your query please mark this post as Solution, thanks!
- AnonymousNot applicable
- m_dekorteResident Rockstar
Hi Anonymous,
Didn't notice you were working with datetime, small adjustment
Table.SelectRows( PrevStepName, each let d = Date.From( DateTime.FixedLocalNow()) in [DateTime] >= DateTime.From( Date.StartOfMonth( Date.AddYears( d, -1))) and [DateTime] <= DateTime.From( d ))
Ps. If this helps solve your query please mark this post as Solution, thanks!