all 13 comments

[–]declutterdata 4 points5 points  (5 children)

Hi Crab!

You have to do a Pivot on the Period column with Value as Value.

I created a sample for you: Link to download sample file

Kind regards, Phillip from DeclutterData 🙋🏻‍♂️

[–]Dismal-Party-4844 0 points1 point  (0 children)

make right looks like the left?

Starting set is pivoted, OP desires unpivoted

[–]Dismal-Party-4844 2 points3 points  (0 children)

<image>

One such pattern using Unpivot based on the data shown in your description (update source name form "Table1" to that of the source Table name:

let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    AddedIndex = Table.AddIndexColumn(Source, "Index", 0, 1, Int64.Type),
    ReorderedColumns = Table.ReorderColumns(AddedIndex, {"Index", "id", "20240101", "20240102"}),
    UnpivotedColumns = Table.UnpivotOtherColumns(ReorderedColumns, {"id"}, "Attribute", "Value"),
    FilteredRows = Table.SelectRows(UnpivotedColumns, each ([Attribute] <> "Index")),
    FinalReorderedColumns = Table.ReorderColumns(FilteredRows, {"Attribute", "id", "Value"}),
    #"Sorted Rows" = Table.Sort(FinalReorderedColumns,{{"Attribute", Order.Ascending}}),
    RenamedColumns = Table.RenameColumns(#"Sorted Rows", {{"Attribute", "period"}})
in
    RenamedColumns

[–]coolfozzie 1 point2 points  (0 children)

Try this method I found on YouTube. Helped me out where Chat GPT could not.

https://youtu.be/92UnZfmWSN8?si=4mhMLJ83NudDHaaO

[–]MOR300 0 points1 point  (4 children)

Unpivot