Reply
avatar user
Anonymous
Not applicable
Partially syndicated - Outbound

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? 

dpibarker_0-1683556167202.png

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. 

dpibarker_1-1683556253161.png

 

 

1 ACCEPTED SOLUTION

Syndicated - Outbound

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!

View solution in original post

3 REPLIES 3
m_dekorte
Super User
Super User

Syndicated - Outbound

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!

avatar user
Anonymous
Not applicable

Syndicated - Outbound

dpibarker_0-1683561486775.png

 

Syndicated - Outbound

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!

avatar user

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors (Last Month)
Top Kudoed Authors (Last Month)