当A1和B1匹配A2和B2时,尝试连接C列中的值

问题描述 投票:-2回答:1

我有三列数据。 A列是计算机列表。 B列是用户ID列表。 C列是用户权限。我想要做的是在A和B匹配时连接C列中的值。附件是我想要做的简单屏幕截图。请告知最简单的方法来实现这一目标。我是Excel公式的新手,所以任何帮助表示赞赏!

Example

excel
1个回答
0
投票

根据您的原始数据,您想要的结果没有意义。

特别是,您的数据中只有两个bbb123,而aaa123有两个不同的匹配。

如果这是错字相关的,你可以用Power Query aka Get&Transform轻松完成你想要的,这是自2010年以来Excel版本的一部分。

除自定义列外,以下大部分代码都可以从用户界面自动生成。

算法:

  • 按机器和帐户对数据进行分组 - 这形成了分组“权限”的表格
  • table转换为list(这就是Custom Column所做的)
  • 通过提取值并使用逗号作为分隔符来展开列表
  • 删除包含tables的列

自定义列的公式为:(从UI添加列/自定义列)

=Table.Column([Grouped],"permissions")` 

M代码:

let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"machine", type text}, {"account", type text}, {"permissions", type text}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"machine", "account"}, {{"Grouped", each _, type table}}),
    #"Added Custom" = Table.AddColumn(#"Grouped Rows", "Custom", each Table.Column([Grouped],"permissions")),
    #"Extracted Values" = Table.TransformColumns(#"Added Custom", {"Custom", each Text.Combine(List.Transform(_, Text.From), ","), type text}),
    #"Removed Columns" = Table.RemoveColumns(#"Extracted Values",{"Grouped"})
in
    #"Removed Columns"

原始数据

enter image description here

分组数据

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.