I want to filter a Power Query column by a range of values. I see that I can manually select or deselect values from the column, but I need to do this automatically absed on a range of values already in the sheet.
Let's say the table I'm querying contains 100 unique names. I only want to import rows that match a list of 20 names I have in my sheet.
How can I do this with Power Query?
Edit: I can make an excel function to concatenate a list of names into the format needed for the query like this: (= Table.SelectRows(#"Changed Type", each ([Ticket Assignee] ="Name 1" or [Ticket Assignee] ="Name 2")))
. But still need a way to reference this from the query.
Edit2:
My query:
This errors out with:
Expression.Error: We expected a FieldsSelector value.
let
names_Source = Excel.CurrentWorkbook(){[Name="namesTable"]}[Content],
names_Values = names_Source{1},
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type datetime}, {"Ticket Assignee", type text}, {"# Solved", Int64.Type}}),
#"Filtered Rows" = Table.SelectRows(#"Changed Type", each ([Ticket Assignee] <> null)),
#"Filtered Rows1" = Table.SelectRows(#"Changed Type", each Record.HasFields(names_Values, [Ticket Assignee]))
in
#"Filtered Rows1"
Edit3: Modified Query:
Expression.Error: We cannot convert the value null to type Record. Details: Value= Type=Type
let
names_Source = Excel.CurrentWorkbook(){[Name="namesTable"]}[Content],
names_Values = Record.FromList(names_Source[Zendesk Name], names_Source[Zendesk Name]),
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type datetime}, {"Ticket Assignee", type text}, {"# Solved", Int64.Type}}),
#"Filtered Rows" = Table.SelectRows(#"Changed Type", each ([Ticket Assignee] <> null)),
#"Filtered Rows1" = Table.SelectRows(#"Filtered Rows", each Record.HasFields(names_Values, [Ticket Assignee]))
in
#"Filtered Rows1"
Edit4: My table has blank values that were erroring out as null. I added a line to filter out the null values from my names source
names_Values = names_Source{1}
, instead usenames_Value = Record.FromList(names_Source[Column1], names_Source[Column1])
. You got the FieldSelector error because#"Filtered Rows1"
refers to the wrong table: you want to filter on#"Filtered Rows"
, not on#"Changed Type"
– Alejandro Lopez-Lago - MSFTWe cannot convert the value null to type Text.
. Is there a way to debug the query to see the exact point or field of failure? Again, thanks for the help. – Douglas Gaskell