The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
I am needing to filter my Date Column by a specified date plus the 6 previous days.
Solved! Go to Solution.
@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
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.
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.
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.
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
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.
@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