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
Cottswald
New Member

Is it Possible to Merge 2 Columns into 1 (by creating new rows)

I have reports automatically emailed to me from my company server. I currently do transformation in Excel, but am looking to get the process setup in PowerBI for automation.

My problem is that the reports are sent in this format, and I cannot change them:

NameType 1Type 2Type 3Type 4Type 5


I would like to use a query in BI to transform the data to this:

NameType 1
NameType 2
NameType 3
NameType 4
NameType 5


I have not been able to find a soultion anywhere to this. Pivoting & un-pivoting columns doesn't do what I am trying to do.
I am trying to merge all my 'Type' columns into a single column, essentially adding it as additional rows to an exisitng column.
Is this even possible in PowerBI? Any suggestions would be greatly appreciated!

1 ACCEPTED SOLUTION
v-yiruan-msft
Community Support
Community Support

Hi @Cottswald ,

I created a sample pbix file(see the attachment), please check if that is what you want.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("RcqhDcNAEETRXg4b5GZnbFfhBqwDAYFh6V+Rviwteejd97je389rjm38JgoLjZljbU8UEYWFxqhjEVFYaEx1NBGFhca4Y4goLDQmHXciCguN2TseRBQWGnN0PIkoLDTmHGv9AQ==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Name = _t, #"Type 1" = _t, #"Type 2" = _t, #"Type 3" = _t, #"Type 4" = _t, #"Type 5" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Name", type text}, {"Type 1", type text}, {"Type 2", type text}, {"Type 3", type text}, {"Type 4", type text}, {"Type 5", type text}}),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"Name"}, "Types", "Value"),
    #"Merged Columns" = Table.CombineColumns(#"Unpivoted Other Columns",{"Name", "Types"},Combiner.CombineTextByDelimiter(" ", QuoteStyle.None),"Merged")
in
    #"Merged Columns"

yingyinr_0-1675839837106.png

Best Regards

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

View solution in original post

2 REPLIES 2
v-yiruan-msft
Community Support
Community Support

Hi @Cottswald ,

I created a sample pbix file(see the attachment), please check if that is what you want.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("RcqhDcNAEETRXg4b5GZnbFfhBqwDAYFh6V+Rviwteejd97je389rjm38JgoLjZljbU8UEYWFxqhjEVFYaEx1NBGFhca4Y4goLDQmHXciCguN2TseRBQWGnN0PIkoLDTmHGv9AQ==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Name = _t, #"Type 1" = _t, #"Type 2" = _t, #"Type 3" = _t, #"Type 4" = _t, #"Type 5" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Name", type text}, {"Type 1", type text}, {"Type 2", type text}, {"Type 3", type text}, {"Type 4", type text}, {"Type 5", type text}}),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"Name"}, "Types", "Value"),
    #"Merged Columns" = Table.CombineColumns(#"Unpivoted Other Columns",{"Name", "Types"},Combiner.CombineTextByDelimiter(" ", QuoteStyle.None),"Merged")
in
    #"Merged Columns"

yingyinr_0-1675839837106.png

Best Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
FreemanZ
Super User
Super User

hi @Cottswald 

try to paste some dummy but concrete data?

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.