Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

Append different columns from one table

Hello, I have a table with four columns: A, B, C, D.  <A>    <B>     <C>      <D> John    Mike    Mark     Robyn Maura Deb     Jim        Tim   I would like to create a new table with all t...
  • v-lili6-msft's avatar
    7 years ago

    HI, Anonymous 

    The best way is Unpivot the columns in Edit Queries.

    For example:

    In Edit Queries, Selected Column B,C,D.

    Then click Transform->Unpivot Columns

    Now remove Attribute column.

    Result:

     

    here is M colde, please try it.

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8srPyFPSUfLNzE4FUYlF2UAqKD+pMk8pVicaKFBalAgUcUlNApJemblAMgRIxsYCAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [A = _t, B = _t, C = _t, D = _t]),
        #"Unpivoted Columns" = Table.UnpivotOtherColumns(Source, {"A"}, "Attribute", "Value"),
        #"Removed Columns" = Table.RemoveColumns(#"Unpivoted Columns",{"Attribute"})
    in
        #"Removed Columns"

    Best Regards,

    Lin