如何在Power查询中自动控制variablesfilter?

有没有一种方法来控制filter在select查询值的基础上给出的值

可以说,我有以下的权力查询,数据如下所示

country type value1 value2.... ---------------------------------------------------------------------- USA a1 22 12 Uk a2 21 10 

现在在电源查询中,我手动过滤这些值,使国家=“美国”,types=“a1”获得数据透视表。

如何在电源查询中使用用户input自动过滤值?

用户input:

  country: [textbox] or workbook cell type : [textbox] or workbook cell 

感谢您的支持!

PS:我的工作查询看起来像下面,

 let Source = Csv.Document(File.Contents("C:\Users\axlptl\Desktop\abc.csv"),[Delimiter=",", Columns=4, Encoding=1252, QuoteStyle=QuoteStyle.None]), UserInput = Excel.CurrentWorkbook(){[Name="Table1"]}[Content][country]{0}, #"Promoted Headers" = Table.PromoteHeaders(Source), #"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"country", type text}, {"type", type text}, {"value1", Int64.Type}, {"value2", Int64.Type}}), #"Filtered Rows" = Table.SelectRows(#"Changed Type", each ([type] = UserInput)) in #"Filtered Rows" 

尝试把22放在一个工作簿单元格(也许在另一个工作表),并从表中select。 基本上,这样做是做什么的: 电力查询和权力支点 – 空表和清空枢纽

你会希望你的查询有一个像这样的行:

 UserInput = Excel.CurrentWorkbook(){[Name="Table1"]}[Content][country]{0}, 

您应该为包含Country和Type参数的单元格创build名称。 比方说,单元格B1是国家,B2是types。 转到公式/名称pipe理器并为其分配相应的名称。

然后(假设您的数据表被命名为Table1),您可以使用以下PowerQuery:

 let Country = Excel.CurrentWorkbook(){[Name="Country"]}[Content][Column1]{0}?, Type = Excel.CurrentWorkbook(){[Name="type"]}[Content][Column1]{0}?, Table = Excel.CurrentWorkbook(){[Name="Table1"]}[Content], Filter = Table.SelectRows(Table, each [country] = Country and [type] = Type) in Filter 

另外要注意名称,它们区分大小写。