Jamie Walker
Jamie Walker

Reputation: 213

How to filter Power Query by date I have pulled in from Excel?

So I have pulled the below date in Excel whose table name is BacklogDate into Power Query to use as a filter with the below code. enter image description here

 let
     Source = Excel.CurrentWorkbook(){[Name="BacklogDate"]}[Content],
     #"Changed Type" = Table.TransformColumnTypes(Source,{{"Backlog Date", type date}}),
     SourceBackLogDate = Record.Field(#"Changed Type"{0},"Backlog Date")
 in
     SourceBackLogDate

Then I'm trying to use it as a filter in the below code but the format is different in the below filter and I can't figure out how to get it to filter by the BackLogDate.

  #"Filtered Rows" = Table.SelectRows(#"Extracted Date", each [DataCollectionDate] = #date(2019, 8, 24) or [DataCollectionDate] = #date(2019, 7, 27))

Any help is greatly appreciated.

Code that worked

 let
     BackLogDate = BackLogDate,
     Source = Sql.Database("JANSQL02", "Data Warehouse"),
     dbo_SFDCOpportunitiesByDay_JAN = 
 Source{[Schema="dbo",Item="SFDCOpportunitiesByDay_JAN"]}[Data],
     #"Extracted Date" = 
 Table.TransformColumns(dbo_SFDCOpportunitiesByDay_JAN, 
{{"DataCollectionDate", DateTime.Date, type date}}),
     #"Filtered Rows" = Table.SelectRows(#"Extracted Date", each 
 [DataCollectionDate] = BackLogDate)
 in
     #"Filtered Rows"

Upvotes: 0

Views: 975

Answers (1)

Jenn
Jenn

Reputation: 647

Here is an example of filtering by a date query named MyDateFilter. Just change the date code for the name of the date query.

FilterByDateQuery = Table.SelectRows(AddCol_CreatedDate, each [Created Date] = MyDateFilter)

Upvotes: 1

Related Questions