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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

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
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.