我已经开发了多个PowerQuery代码。现在,我准备将它们放入文本文件和/或使用VBA在Excel工作簿之间传输它们。我想尽我所能将所有部分折叠在一起,以简化这些转移。
是否可以有条不紊地将一个PowerQuery查询的M代码集成到另一个PowerQuery查询的M代码中?
查询1:“ MainPowerQueryQuery”
TypeError: expected string or bytes-like object
查询2:“ AnotherPowerQueryQuery”
let
Source = Table.NestedJoin(#"dqyDirLevel3-Excel-PathsAndKeys",{"KeyField"},#"AnotherPowerQueryQuery",{"KeyField"},"AnotherPowerQueryQuery",JoinKind.Inner),
#"Expanded Column of Tables of Data" = Table.ExpandTableColumn(Source, "AnotherPowerQueryQuery", {"Index", "SEQUENCE", "ID", "UNIT", "SYSTEM", "INSTANCE", "SYSTEM-COUNT", "SHORT", "LS", "AS", "RS", "S_", "AE", "STATUS", "AN"}, {"Index", "SEQUENCE", "ID", "UNIT", "SYSTEM", "INSTANCE", "SYSTEM-COUNT", "SHORT", "LS", "AS", "RS", "S_", "AE", "STATUS", "AN"})
in
#"Expanded Column of Tables of Data"
我正在寻找一个由查询1的副本内部的查询2的代码组成的查询3,这样我就可以删除查询1和2,并仅保留查询3。
答案 0 :(得分:1)
您可以在一个查询中组合步骤:
let
LookupTable = Excel.Workbook(File.Contents("\\share\path\to\my\other\Workbook.xlsx"), null, true){[Item="tblPX",Kind="Table"]}[Data],
Source = Table.NestedJoin(#"dqyDirLevel3-Excel-PathsAndKeys",{"KeyField"},LookupTable,{"KeyField"},"LookupTable",JoinKind.Inner),
#"Expanded Column of Tables of Data" = Table.ExpandTableColumn(Source, "LookupTable", {"Index", "SEQUENCE", "ID", "UNIT", "SYSTEM", "INSTANCE", "SYSTEM-COUNT", "SHORT", "LS", "AS", "RS", "S_", "AE", "STATUS", "AN"}, {"Index", "SEQUENCE", "ID", "UNIT", "SYSTEM", "INSTANCE", "SYSTEM-COUNT", "SHORT", "LS", "AS", "RS", "S_", "AE", "STATUS", "AN"})
in
#"Expanded Column of Tables of Data"