Power Query Solution to transform table

  Kiến thức lập trình

I have 2 tables following the picture, table 1 is from pdf file and I want to use power query to change to table 2, if power query can’t use, any library in Python could do that.

Update

To clarify, I mean in table 1, one row will be the name of the column, one row is value, and it’s interleave, and any way to transform it to table 2.

In powerquery, you can do this (your revised request)

let Source = Excel.CurrentWorkbook(){[Name="Table2"]}[Content],
AnchorColumn=List.Last(Table.ColumnNames(Source)),
a = Table.RemoveColumns(Table.UnpivotOtherColumns(Table.AlternateRows(Source,1,1,1), {AnchorColumn}, "Attribute", "Value"),{"Attribute"}),
b = Table.RemoveColumns(Table.UnpivotOtherColumns(Table.AlternateRows(Source,0,1,1), {AnchorColumn}, "Attribute", "Value"),{"Attribute"}),
combined = Table.FromColumns(Table.ToColumns(a)&{b[Value]}),
#"Pivoted Column" = Table.Pivot(combined, List.Distinct(combined[Column2]), "Column2", "Column3")
in  #"Pivoted Column"

1

Theme wordpress giá rẻ Theme wordpress giá rẻ Thiết kế website Kho Theme wordpress Kho Theme WP Theme WP

LEAVE A COMMENT