Forum Discussion

marketingVE's avatar
marketingVE
Frequent Visitor
5 years ago
Solved

Combining and merge two rows in one

Hi everyone!   I would to like to know if is possible to merge two rows of the different tables in the one row in power query,  for exemple:   I have this:   Origin       Name     Email        ...
  • Icey's avatar
    5 years ago

    Hi marketingVE ,

     

    You can also try this:

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCklMyklVMFTSUfLKyM+DUg75pSU5+fnZesn5uUAhp6LEqswcIAOEYnVgmozwagIiI1OQ5pzSVCRNIJsccyshJPH24NICssUEbkssAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Origin = _t, Name = _t, Email = _t, Country = _t, Age = _t, Color = _t]),
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"Origin", type text}, {"Name", type text}, {"Email", type text}, {"Country", type text}, {"Age", Int64.Type}, {"Color", type text}}),
        #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"Name", "Email", "Origin"}, "Attribute", "Value"),
        #"Filtered Rows" = Table.SelectRows(#"Unpivoted Other Columns", each ([Value] <> "")),
        #"Removed Columns" = Table.RemoveColumns(#"Filtered Rows",{"Origin"}),
        #"Pivoted Column" = Table.Pivot(#"Removed Columns", List.Distinct(#"Removed Columns"[Attribute]), "Attribute", "Value")
    in
        #"Pivoted Column"

     

     

    Best Regards,

    Icey

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.