Power Query:附加表而不创建重复项

Power Query: Appending tables without creating duplicates

我有两个table。

使用 Power Query:

我想将这些 table 附加到一个 table 中,并用一列指示数据来自两个 table 中的哪一个。

我不希望附加的 table 中有重复值 - 所以我想保留 'FYTD LY' 中的所有数据,并且只将它与 'FULL FY LY' 中没有的数据相结合' 已经存在于 'FYTD LY' table.

不幸的是,我的 table 不包含 ID 列,我无法从可用列中创建一个(我可以确定它会保持唯一)。

这在 Power Query 中是否可行 - 我将如何处理?

看看这是否对你有帮助

最简单的方法....将您的第一个 table 加载到 powerquery,关闭文件并加载。

将第二个 table 加载到 powerquery。

添加列...自定义列..使用公式="第二个table"

主页 ..追加查询 ..追加其他 table

单击 select 除自定义列之外的所有列,右键单击并删除重复项

完成。

Table2 的完整代码(假设您已经使用 Table1 中的数据创建了查询 Table1):

let Source = Excel.CurrentWorkbook(){[Name="Table2"]}[Content],
#"Added Custom" = Table.AddColumn(Source, "From", each "Second Table"),
#"Added Index" = Table.Combine({#"Added Custom",Table1}),
#"Removed Duplicates" = Table.Distinct(#"Added Index", {"a", "b", "c"})
in  #"Removed Duplicates"

如果你想花哨,把公式换成Table1 所以

= Table.Combine({#"Added Custom",Table1}),

变成

= Table.Combine({#"Added Custom",Table.AddColumn(Table1, "From", each "First Table")}),