Hi @haroonali1000,
Without the data and your previous transformations, I can’t tell if there’s a better solution - but this seems to do the trick…
let
Source = myTable,
#"Changed Type" = Table.TransformColumnTypes(Source,{{"ProposalID", Int64.Type}, {"EmployeeID", Int64.Type}, {"DateUpdate", type datetime}, {"Attribute", type text}, {"Value", type any}}),
#"Added Index" = Table.AddIndexColumn(#"Changed Type", "Index", 1, 1),
#"Added Custom" = Table.AddColumn(#"Added Index", "Mod", each Number.Mod([Index], 3)),
#"Removed Other Columns" = Table.SelectColumns(#"Added Custom",{"ProposalID", "EmployeeID", "DateUpdate", "Attribute", "Value", "Mod"}),
#"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Removed Other Columns", {"Mod"}, "Attribute.1", "Value.1"),
#"Grouped Rows" = Table.Group(#"Unpivoted Other Columns", {"Mod"}, {{"Count", each _, type table [Mod=number, Attribute.1=text, Value.1=anynonnull]}}),
#"Added Custom1" = Table.AddColumn( #"Grouped Rows", "Custom", each Table.PromoteHeaders( Table.Transpose(Table.RemoveColumns([Count],"Mod")), [PromoteAllScalars=true])),
#"Expanded Custom" = Table.ExpandTableColumn(#"Added Custom1", "Custom", {"ProposalID", "EmployeeID", "DateUpdate", "Attribute", "Value", "ProposalID_1", "EmployeeID_2", "DateUpdate_3", "Attribute_4", "Value_5", "ProposalID_6", "EmployeeID_7", "DateUpdate_8", "Attribute_9", "Value_10"}, {"ProposalID", "EmployeeID", "DateUpdate", "Attribute", "Value", "ProposalID_1", "EmployeeID_2", "DateUpdate_3", "Attribute_4", "Value_5", "ProposalID_6", "EmployeeID_7", "DateUpdate_8", "Attribute_9", "Value_10"}),
#"Removed Other Columns1" = Table.SelectColumns(#"Expanded Custom",{"ProposalID", "EmployeeID", "DateUpdate", "Attribute", "Value", "Attribute_4", "Value_5", "Attribute_9", "Value_10"})
in
#"Removed Other Columns1"
Your data is in pairs of three, so I added an Index from 1 and used the MOD to identify the pairs.
Unpivoted Other Columns and Grouped All Rows by MOD
Transformed that table, by first removing the MOD column then Promoting the Headers and finally
Transposing it. Now you’re left with a single row.
Expanded that table and Removed some columns
I hope this is helpful, here’s my file eDNA Forum - Query Editor Unpivot.pbix (41.0 KB)