Forum Discussion

p0nk's avatar
p0nk
Frequent Visitor
8 years ago
Solved

Combining multiple columns in a single table into one long column

Hello all,

 

I may be missing something/not looking hard enough, but I cannot figure out a way to do this. I have 3 columns as shown in the image below that I want to combine into one long column.

 

 

 

Ideally I would like to do this in the query editor without using calculated columns or creating any new tables, but this is not a nessecity. I can't find a solution to this anywhere and was wondering if any of you knew.

 

Thanks.

  • If you don't need the null values, then you can unpivot all columns:

     

    let
        Source = Input,
        #"Unpivoted Only Selected Columns" = Table.Unpivot(Source, {"Column1", "Column2", "Column3"}, "Attribute", "Conference Type"),
        #"Removed Columns" = Table.RemoveColumns(#"Unpivoted Only Selected Columns",{"Attribute"})
    in
        #"Removed Columns"

     

    If you want to keep the null values, then you can convert the table into columns (lists), combine these lists and convert the result back to a table:

     

    let
        Source = Input,
        Result = Table.FromColumns({List.Combine(Table.ToColumns(Source))},type table[#"Conference Type" = text])
    in
        Result

2 Replies

  • MarcelBeug's avatar
    MarcelBeug
    Icon for Community Champion rankCommunity Champion

    If you don't need the null values, then you can unpivot all columns:

     

    let
        Source = Input,
        #"Unpivoted Only Selected Columns" = Table.Unpivot(Source, {"Column1", "Column2", "Column3"}, "Attribute", "Conference Type"),
        #"Removed Columns" = Table.RemoveColumns(#"Unpivoted Only Selected Columns",{"Attribute"})
    in
        #"Removed Columns"

     

    If you want to keep the null values, then you can convert the table into columns (lists), combine these lists and convert the result back to a table:

     

    let
        Source = Input,
        Result = Table.FromColumns({List.Combine(Table.ToColumns(Source))},type table[#"Conference Type" = text])
    in
        Result
    • p0nk's avatar
      p0nk
      Frequent Visitor

      Works perfectly, thanks!