Aggregate, Collate and Transpose rows into columns

后端 未结 3 1409
一整个雨季
一整个雨季 2020-11-27 23:45

I have the following table

 Id     Letter
1001    A
1001    H
1001    H
1001    H

1001    B
1001    H
1001    H
1001    H

1001    H
1001    H
1001    H

10         


        
3条回答
  •  天涯浪人
    2020-11-28 00:34

    For tasks like this Microsoft added "Get&Transform" to Excel 2016. In order to use this functionality in earlier versions, you have to use the Power Query Add-In. The M-code is very short:

    let
        Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
        FillIdDown = Table.FillDown(Source,{"Id"}),
        ReplaceNull = Table.ReplaceValue(FillIdDown,null," ",Replacer.ReplaceValue,{"Letter"}),
        Transform = Table.Group(ReplaceNull, {"Id"}, {{"Count", each Text.Combine(_[Letter])}})
    in
        Transform
    

    Your data should sit in "Table1". https://www.dropbox.com/s/bnvchofmpvd048v/SO_AggregateCollateAndTransposeColsIntoRows.xlsx?dl=0

提交回复
热议问题