Power Query - Transpose unique values and get matc

2019-08-15 06:27发布

I am trying to transform a very simple input_table

enter image description here

into this output_table:

enter image description here

I am basically trying to:

  • Get unique items in first column
  • Transpose and promote these items as column headers
  • Get matching values (from the second column in input_table) under each unique header

I am using Power Query because I need the output_table to dynamically update each time I add records to input_table, but any other dynamical solution is accepted (Array Formulas, intermediate Tables, etc...). No VBA.

1条回答
小情绪 Triste *
2楼-- · 2019-08-15 06:55

Assuming your table is called Table1 and is structured in the way shown in the screenshot, I think this Power Query query should do what you want:

let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    ChangedType = Table.TransformColumnTypes(Source,{{"Type", type text}, {"Value", type text}}),
    GroupedRows = Table.Group(ChangedType, {"Type"}, {{"DistinctValues", each _[Value]}}),
    Output = Table.FromColumns(GroupedRows[DistinctValues], GroupedRows[Type])
in
    Output

Chris

查看更多
登录 后发表回答