Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
p0nk
Frequent Visitor

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.

 

12345.PNG

 

 

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.

1 ACCEPTED SOLUTION
MarcelBeug
Community Champion
Community 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
Specializing in Power Query Formula Language (M)

View solution in original post

2 REPLIES 2
MarcelBeug
Community Champion
Community 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
Specializing in Power Query Formula Language (M)

Works perfectly, thanks!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.