Power Query - Transpose unique values and get matching values in rows

时光怂恿深爱的人放手 提交于 2019-12-11 13:44:53

问题


I am trying to transform a very simple input_table

into this output_table:

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:


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



来源:https://stackoverflow.com/questions/36518002/power-query-transpose-unique-values-and-get-matching-values-in-rows

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!