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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Syndicate_Admin
Administrator
Administrator

Power Query Date filter for not older than Today - 150 Days

I am trying to create a date filter to exclude items where the date is greater than today - 150 days.

Based on some research, I have come up with the below; however, it is excluding Today!

Any help would be greatly appreciated 

 

= Table.SelectRows(#"Sorted Rows", each Date.IsInPreviousNDays([Finish Date], 150) or Date.IsInNextNDays([Finish Date], 1000))

2 ACCEPTED SOLUTIONS
PhilipTreacy
Super User
Super User

Hi @Syndicate_Admin  @DonalMc 

 

I'm a bit confused. You want to exclude rows wheer the date is greater than today -150?  But your code keeps those rows?

 

Your code will exclude today because today falls inside yoru exclusion criteria.  Today's date is greater than today - 150 days.

 

To keep rows where the date is greater than today -150

 

= Table.SelectRows(#"Sorted Rows", each Date.IsInPreviousNDays([Finish Date], 150) or [Finish Date] = Date.From(DateTime.LocalNow()))

 

To exclude these rows

 

= Table.SelectRows(#"Sorted Rows", each not (Date.IsInPreviousNDays([Finish Date], 150) or [Finish Date] = Date.From(DateTime.LocalNow())))

 

Phil 



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


View solution in original post

DonalMc
Advocate II
Advocate II

Hi Phil,

Yes - apologies for my clumsiness - I was trying to exclude items that were less than today -150, i.e. only show items that had a date greater than today - 150 days.

Your code helped me, but for some reason excluded items after today. I adapted your code and to the below and now have the result I need.

Thanks for the help

 

= Table.SelectRows(#"Sorted Rows", each Date.IsInPreviousNDays([Finish Date], 150) or [Finish Date] = Date.From(DateTime.LocalNow()) or Date.IsInNextNDays([Finish Date], 900000) )

View solution in original post

2 REPLIES 2
DonalMc
Advocate II
Advocate II

Hi Phil,

Yes - apologies for my clumsiness - I was trying to exclude items that were less than today -150, i.e. only show items that had a date greater than today - 150 days.

Your code helped me, but for some reason excluded items after today. I adapted your code and to the below and now have the result I need.

Thanks for the help

 

= Table.SelectRows(#"Sorted Rows", each Date.IsInPreviousNDays([Finish Date], 150) or [Finish Date] = Date.From(DateTime.LocalNow()) or Date.IsInNextNDays([Finish Date], 900000) )

PhilipTreacy
Super User
Super User

Hi @Syndicate_Admin  @DonalMc 

 

I'm a bit confused. You want to exclude rows wheer the date is greater than today -150?  But your code keeps those rows?

 

Your code will exclude today because today falls inside yoru exclusion criteria.  Today's date is greater than today - 150 days.

 

To keep rows where the date is greater than today -150

 

= Table.SelectRows(#"Sorted Rows", each Date.IsInPreviousNDays([Finish Date], 150) or [Finish Date] = Date.From(DateTime.LocalNow()))

 

To exclude these rows

 

= Table.SelectRows(#"Sorted Rows", each not (Date.IsInPreviousNDays([Finish Date], 150) or [Finish Date] = Date.From(DateTime.LocalNow())))

 

Phil 



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors