Forum Discussion
Date Filter to include the previous 6 Days
I am needing to filter my Date Column by a specified date plus the 6 previous days.
ALW0120 Hi! which is the specified date? You can adapt the following code:
FilteredRows = Table.SelectRows(#"ExtractedDate", each [PlanDate] >= Date.AddDays(DateTime.FixedLocalNow(), -6)
and [PlanDate] <= DateTime.FixedLocalNow())i've used FixedLocalNow, but you can put any date.
BBF
You can achieve this in Power Query by adding a custom column that checks if the date falls within the specified range. Here’s how:
Define your target date (e.g., #date(2025, 3, 😎 for March 8, 2025).
Create a filter condition to keep dates between the target date and 6 days before it.TargetDate = #date(2025, 3, 8), // Change this to your desired date
StartDate = TargetDate - #duration(6,0,0,0),
[Date Column] >= StartDate and [Date Column] <= TargetDate
6 Replies
- BeaBFSuper User
ALW0120 Hi! which is the specified date? You can adapt the following code:
FilteredRows = Table.SelectRows(#"ExtractedDate", each [PlanDate] >= Date.AddDays(DateTime.FixedLocalNow(), -6)
and [PlanDate] <= DateTime.FixedLocalNow())i've used FixedLocalNow, but you can put any date.
BBF
- V-yubandi-msftCommunity Support
Hello ALW0120 ,
Thank you for your valuable input, BeaBF .
ALW0120 , BeaBF has provided an accurate solution to your issue. Could you please confirm if it meets your requirements? If you need any further clarification.
If your issue is resolved, kindly mark it as the Accepted Solution. Otherwise, let us know how we can assist you further.
Regards,
Yugandhar.
- Omid_MotamediseSuper User
You can achieve this in Power Query by adding a custom column that checks if the date falls within the specified range. Here’s how:
Define your target date (e.g., #date(2025, 3, 😎 for March 8, 2025).
Create a filter condition to keep dates between the target date and 6 days before it.TargetDate = #date(2025, 3, 8), // Change this to your desired date
StartDate = TargetDate - #duration(6,0,0,0),
[Date Column] >= StartDate and [Date Column] <= TargetDate - V-yubandi-msftCommunity Support
Hi ALW0120 ,
We noticed we haven't received a response from you yet, so we wanted to follow up and ensure the solution we provided addressed your issue. If you require any further assistance or have additional questions, please let us know.
Your feedback is valuable to us, and we look forward to hearing from you soon.
Thak You. - V-yubandi-msftCommunity Support
Hi ALW0120 ,
Has your issue been resolved, or do you require any further information? Your feedback is valuable to us. If the solution was effective, please mark it as 'Accepted Solution' to assist other community members experiencing the same issue.
Thank You. - V-yubandi-msftCommunity Support
Hi ALW0120 ,
May I ask if you have resolved this issue? If so, please mark the helpful reply and accept it as the solution. This will be helpful for other community members who have similar problems to solve it faster.
Thank you.