Code from above was for example from OP
Here is more flexible code
Code:let Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content], TypeRD = Table.Distinct(Table.TransformColumnTypes(Source,{{"Values", type text}})), GR = Table.Group(TypeRD, {"Code"}, {{"GrBy", each Table.Transpose(Table.FromList([Values]))}}), MT = Table.AddColumn(GR, "ColCount", each Table.ColumnCount([GrBy])), LD = List.Distinct(List.Combine(Table.AddColumn(MT, "ColNames", each Table.ColumnNames([GrBy]))[ColNames])), EXRC = Table.RemoveColumns(Table.ExpandTableColumn(MT,"GrBy",LD),{"ColCount"}), UNP = Table.UnpivotOtherColumns(EXRC, {"Code"}, "Attribute", "Value"), RPL = Table.ReplaceValue(Table.TransformColumnTypes(UNP,{{"Value", Int64.Type}}),"Column","Value",Replacer.ReplaceText,{"Attribute"}), PVT = Table.Pivot(RPL, List.Distinct(RPL[Attribute]), "Attribute", "Value") in PVT
A B C D E F G H I J K L M 1Code Values Code Value1 Value2 Value3 Value4 Value5 Value6 Value7 Value8 2 1001 2101 1001 2101 2605 5205 9285 3 1001 2605 2604 3555 4256 7458 4 1001 5205 3111 1218 1222 1226 1230 1234 1235 1236 1237 5 1001 9285 6 2604 3555 7 2604 4256 8 2604 7458 9 3111 1218 10 3111 1222 11 3111 1226 12 3111 1230 13 3111 1234 14 3111 1234 15 3111 1235 16 3111 1236 17 3111 1237
btw. functions UNIQUE and FILTER are for EX365 and higher but not lower version





Reply With Quote
Bookmarks