Power Query - 连接和转置

Power Query - Concatenate and Transpose

我在下面有一个数据 table (1),我想要 table (2) 中的结果。我该怎么做?

看看这个主题:VBA excel, concatenate cells when there are duplicates .

您可以使用该 vlookupall 函数,然后对结果使用 "Text to column"。

我建议如下:

  • 使用“移除行”>“移除重复项”删除重复行
  • 使用串联 () 对 table 进行分组
  • 使用“拆分列”>“按分隔符”拆分串联的 State 列。

您可以使用此代码:

let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    group = Table.Group(Source, {"Name"}, {{"State", each Text.Combine(List.Distinct([State]), "|")}}),
    split = Table.SplitColumn(group, "State", Splitter.SplitTextByDelimiter("|", QuoteStyle.Csv), {"State.1", "State.2", "State.3"})
in
    split

result