In a query developed with Excel Power Query I would like to replace the table column name with a variable, when I filter rows of a list. Unfortunately, I either get an error message (e.g. Expression Error: Column xx of table was not found) or no row is remaining after filtering even if it should. In the example below the variable #"Filter" (= column name) is set to column "B" and used in the step #"Filter Rows" to filter the rows which contain a '1'. But the result is that no row is shown. Any idea what's the reason and how to solve this? Maybe the variable needs to have a special data type?
Thanks in advance!
Table: Table to be filtered
Code:
let
#"Filter" = "B",
Source = Excel.CurrentWorkbook(){[Name="Tabelle2"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"A", Int64.Type}, {"B", Int64.Type}}),
#"Changed Type1" = Table.TransformColumnTypes(#"Changed Type",{{#"Filter", type text}}),
#"Filtered Rows" = Table.SelectRows(#"Changed Type1", each Text.Contains(#"Filter", "1"))
in
#"Filtered Rows"