Forum Discussion
Looking to restrict power query to last 100 days
Hello, I'm attempting to use excel to restrict the data from my database to the last 100 days. Currently the query restricts to a "is greater than date" format which works but the file becomes very large and slow quickly. Without having to go in and manually adjust the date to a later date each time, is there a way to just make this a "rolling 100 day" extraction from the database?
I have heard there is a filter called "is in the previous" for some versions of excel but i dont see that in my power query filters.
Excel Version: O365 MSO 16.0.13901.20276
Database: Sql Server
Hi HenriG
If your version of Excel/PQ doesn't have function https://docs.microsoft.com/en-us/powerquery-m/date-isinpreviousndays you can get the same result using the following approach, assuming the column to filter is called [Date] (update #"Previous Step Name" below):
= Table.SelectRows(#"Previous Step Name", each DateTime.Date([Date]) >= DateTime.Date(Date.AddDays(DateTime.FixedLocalNow(), -100)) )
3 Replies
- LorenzoSilver Contributor
Hi HenriG
If your version of Excel/PQ doesn't have function https://docs.microsoft.com/en-us/powerquery-m/date-isinpreviousndays you can get the same result using the following approach, assuming the column to filter is called [Date] (update #"Previous Step Name" below):
= Table.SelectRows(#"Previous Step Name", each DateTime.Date([Date]) >= DateTime.Date(Date.AddDays(DateTime.FixedLocalNow(), -100)) )