Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
Zedders12345
New Member

Date is NOT within previous N months

Hi everyone 

 

Im using power query to manipulate some data and i wand to date filer where a date is NOT within the previous N months.  There is and option to filter if it IS within previous months but it isnt clear ho to request the opposite

 

Any help would be very much appreciated 

 

Thank you 

1 REPLY 1
Daryl-Lynch-Bzy
Resident Rockstar
Resident Rockstar

Hi @Zedders12345 - the Date.IsInPreviousMonths function is logical so it returns true/false, so you simply need to add "not" before the function to change from true (in previous months) to false.  However, the function could return future dates, so it is best to exclude these.


//Return rows before and after the previous 3 months
Table.SelectRows(Source, each not Date.IsInPreviousNMonths([Date], 3))

//Return rows before and after the previous 3 months
Table.SelectRows(Source, each not Date.IsInPreviousNMonths([Date], 3) 
and [Date] < Date.From(DateTime.FixedLocalNow()) )

Helpful resources

Announcements
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.