Forum Discussion
LazyMirdon
Jul 03, 2025Copper Contributor
How to transform wide-format data into the structure shown in 'Result' sheet using Power Query?
Hi everyone, I have a dataset in wide format in the "Data" sheet, and I’d like to reshape it using Power Query to match the format shown in the "Result" sheet. What the source looks like (Data shee...
Kidd_Ip
Jul 03, 2025MVP
Try the following:
let
// Load the source table
Source = Excel.CurrentWorkbook(){[Name="Data"]}[Content],
// Unpivot all date-measure columns
Unpivoted = Table.UnpivotOtherColumns(Source, {"Product Brand", "Product Name", "Region"}, "Attribute", "Value"),
// Split the 'Attribute' column into Date and Measure
SplitColumn = Table.SplitColumn(Unpivoted, "Attribute", Splitter.SplitTextByEachDelimiter({" "}, QuoteStyle.Csv, false), {"DateText", "Measure"}),
// Convert the date string to actual date format (assuming dd.MM)
AddedYear = Table.AddColumn(SplitColumn, "Date", each Date.FromText("2025-" & Text.Middle([DateText], 3, 2) & "-" & Text.Start([DateText], 2)), type date),
// Remove the original DateText column
RemovedDateText = Table.RemoveColumns(AddedYear, {"DateText"}),
// Reorder columns for clarity
Reordered = Table.ReorderColumns(RemovedDateText, {"Product Brand", "Product Name", "Region", "Date", "Measure", "Value"})
in
Reordered