Showing results for 
Search instead for 
Did you mean: 
Helper IV
Helper IV

Power Query - Filter columns where the date is less than the current week



I'd like to filter my source data to show me all records up to the current week, but not including the current week. I've tried adding a custom column where I create a "Today Week" by doing:

= Table.AddColumn(#"Added Custom2", "Week (Today)", each Date.WeekOfYear(DateTime.LocalNow()))


= Table.AddColumn(#"Merged Columns", "Year (Today)", each Date.Year(DateTime.LocalNow()))


Then joining the two fields together, but I'm not seeing how I could then filter my existing year week by this?


Additionally, the formatting gets skewed on the week for when it's single digits - if this was the path to go down, how to I pad it with an extra leading 0 where it's a week number less than 10?


Many thanks for your help,


Community Support
Community Support

Hi, @Dayna 

1.As a workaround, you might consider adding an extra column or a parameter 'Start of week' to get the start date of the current week

=Table.AddColumn(#"Added Custom", "Start of Week(Today)", each Date.StartOfWeek(DateTime.LocalNow()))

 and then filter all data with dates less than the start date of the current week.

= Table.SelectRows(#"Inserted Start of Week", each [Date] < Date.StartOfWeek(DateTime.LocalNow()))

Here you need to confirm that the data types of the columns are the same(Date/Time)


2.You can try Text.PadStart to format the WeekOfYear.

=Table.AddColumn(#"Inserted Week of Year1", "New week of Year", each Text.PadStart(Text.From([Week of Year], "en-US"), 2, "0"), type text)



Best Regards,
Community Support Team _ Eason

Helpful resources

June 2022 update 768X460.jpg

Check it out!

Click here to read more about the June 2022 updates!

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Power BI Dev Camp Session 23 768x460.jpg

Check it Out!

Mark your calendars and join us on Thursday, June 30 at 11a PDT for a great session with Ted Pattison!

June 20 episode 7 with aka link 768x460.jpg

The Power BI Community Show

Join us on June 20 at 11 am PDT when Kim Manis shares the latest on Azure Synapse analytics, the Microsoft Intelligent Data Platform, and notable Power BI Updates from Microsoft Build 2022.

Top Solution Authors