Forum Discussion
Need to filter one column based on value in another query
- 5 years ago
Hi Anonymous
Attached are an Excel workbook and a PBIX file containing the 2 queries that filter as you require.
The first query loads the Start and End dates.
The 2nd query loads the table of dates/tickets and filters using the dates from the first query.
In the M code in the PBIX file, you will need to change the folder that the file is loaded from.
Query 1 - Load Start and End Dates
let Source = Excel.Workbook(File.Contents("D:\temp\bogachev\bogachev.xlsx"), null, true), Start_End_Table = Source{[Item="Start_End",Kind="Table"]}[Data], #"Changed Type" = Table.TransformColumnTypes(Start_End_Table,{{"Start", type datetime}, {"End", type datetime}}) in #"Changed Type"Query 2 - Load Data Table and Filter
let Source = Excel.Workbook(File.Contents("D:\temp\bogachev\bogachev.xlsx"), null, true), Tickets_Table = Source{[Item="Tickets",Kind="Table"]}[Data], #"Changed Type" = Table.TransformColumnTypes(Tickets_Table,{{"Closed date", type datetime}, {"Ticket #", Int64.Type}}), #"Filtered Rows" = Table.SelectRows(#"Changed Type", each [Closed date] >= Start_End[Start]{0} and [Closed date] <= Start_End[End]{0}) in #"Filtered Rows"Regards
Phil
If I answered your question please mark my post as the solution.
If my answer helped solve your problem, give it a kudos by clicking on the Thumbs Up.
Hi Anonymous
Attached are an Excel workbook and a PBIX file containing the 2 queries that filter as you require.
The first query loads the Start and End dates.
The 2nd query loads the table of dates/tickets and filters using the dates from the first query.
In the M code in the PBIX file, you will need to change the folder that the file is loaded from.
Query 1 - Load Start and End Dates
let
Source = Excel.Workbook(File.Contents("D:\temp\bogachev\bogachev.xlsx"), null, true),
Start_End_Table = Source{[Item="Start_End",Kind="Table"]}[Data],
#"Changed Type" = Table.TransformColumnTypes(Start_End_Table,{{"Start", type datetime}, {"End", type datetime}})
in
#"Changed Type"
Query 2 - Load Data Table and Filter
let
Source = Excel.Workbook(File.Contents("D:\temp\bogachev\bogachev.xlsx"), null, true),
Tickets_Table = Source{[Item="Tickets",Kind="Table"]}[Data],
#"Changed Type" = Table.TransformColumnTypes(Tickets_Table,{{"Closed date", type datetime}, {"Ticket #", Int64.Type}}),
#"Filtered Rows" = Table.SelectRows(#"Changed Type", each [Closed date] >= Start_End[Start]{0} and [Closed date] <= Start_End[End]{0})
in
#"Filtered Rows"Regards
Phil
If I answered your question please mark my post as the solution.
If my answer helped solve your problem, give it a kudos by clicking on the Thumbs Up.
Hello PhilipTreacy . Thank you! It works 🙂