Ghi chú
Đây là một trong loạt bài viết chi tiết các giải pháp được gửi đến cho thử thách Podcast 2316.
Trong khi giao diện Power Query rất mạnh mẽ, những người có thể vượt ra ngoài giao diện sẽ có siêu năng lực. Frank Tonsen đã gửi giải pháp này. Hãy xác định điểm dữ liệu trông như thế này:

Frank sau đó mã hóa một Table.Split, chỉ định rằng cứ 5 bản ghi phải là một bảng mới.

Từ đó, Table.FromList và hơn thế nữa. Tại thời điểm đó, bạn có thể nhấp vào bất kỳ ô nào của Bảng và xem dữ liệu trong bảng đó. Đây là ô Bảng thứ hai.

Đây là mã của Frank:
let Source = Excel.CurrentWorkbook()((Name="UglyData"))(Content), RemovedTotals = Table.RemoveColumns(Source,("Column2", "Column3", "Column4", "Column5", "Column6")), TransposedTable = Table.Transpose(RemovedTotals), PromotedHeaders = Table.PromoteHeaders(TransposedTable, (PromoteAllScalars=true)), SplittedTable = Table.Split(PromotedHeaders,5), TableFromList = Table.FromList(SplittedTable, Splitter.SplitByNothing(), null, null, ExtraValues.Error), AddedColumn1 = Table.AddColumn(TableFromList, "Column2", each Table.PromoteHeaders(Table.Transpose(Table.DemoteHeaders((Column1))))), AddedColumn2 = Table.AddColumn(AddedColumn1, "Column3", each Table.AddColumn((Column2), "Employee", (x) => Table.ColumnNames((Column2))(1))), AddedColumn3 = Table.AddColumn(AddedColumn2, "Column4", each Table.RenameColumns((Column3), (Table.ColumnNames((Column3))(1), "Total"))), Combined = Table.Combine(AddedColumn3(Column4)), ReorderedColumns = Table.ReorderColumns(Combined,("Category Description", "Employee", "Q1", "Q2", "Q3", "Q4", "Total")), ChangedType = Table.TransformColumnTypes(ReorderedColumns,(("Category Description", type text), ("Employee", type text), ("Q1", type number), ("Q2", type number), ("Q3", type number), ("Q4", type number), ("Total", type number))) in ChangedType
Goodly từ YouTube cũng đã chia sẻ một video với giải pháp M tùy chỉnh để xác định động tất cả các cột bắt đầu bằng "Nhân viên". Mặc dù điều này sẽ không hoạt động trong đời thực khi các nhân viên có tên Andy, Betty, Charlie, nhưng đó là một video thú vị: https://www.youtube.com/watch?v=xamU5QLNiew.
Quay lại trang chính cho thử thách Podcast 2316.
Đọc bài tiếp theo trong loạt bài này: Power Query: Thế giới của Bill Szysz.