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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
pezwi
Frequent Visitor

Merge data into one column from records with multiple entries.

Hi,

I am trying to merge the data in one column in order to show all of our tagging and I'm wondering if it's possible because I can't seem to find a way or I'm searching for the wrong thing.

The current scenario shows the host name and each host could have multiple tags.  The results needed that I'm trying to figure out is it would show one host record and merge the Tag records into one column.

 

Current Scenario:  Results Needed:   
Host NameTag  Host Name New Column
Computer1Prod  Computer1 Prod, Customer1
Computer1Customer1  Computer2 UAT, Customer2, Application1
Computer2UAT     
Computer2Customer2     
Computer2Application1     

 

Any help would be greatly appreciated.

 

Thank you,

 

MIke

1 ACCEPTED SOLUTION
Anonymous
Not applicable

immagine.png

 

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45Wcs7PLSgtSS0yVNJRCijKT1GK1UEVdC4tLsnPBbGRZYyAMqGOIRhiMNVGGDKOBQU5mcmJJZn5eZhGIUsmYjgBSTY0L18pNhYA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Host Name" = _t, Tag = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Host Name", type text}, {"Tag", type text}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Host Name"}, {{"New", each Text.Combine([Tag], ", #(lf)")}})
in
    #"Grouped Rows"

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

immagine.png

 

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45Wcs7PLSgtSS0yVNJRCijKT1GK1UEVdC4tLsnPBbGRZYyAMqGOIRhiMNVGGDKOBQU5mcmJJZn5eZhGIUsmYjgBSTY0L18pNhYA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Host Name" = _t, Tag = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Host Name", type text}, {"Tag", type text}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Host Name"}, {{"New", each Text.Combine([Tag], ", #(lf)")}})
in
    #"Grouped Rows"
mahoneypat
Employee
Employee

Here is one way to do it in the query editor.  To see how it works, just create a blank query, go to the Advanced Editor, and replace the text there with the M code below.

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45Wcs7PLSgtSS0yVNJRCijKT1GK1UEVdC4tLsnPBbGRZYyAMqGOIRhiMNVGGDKOBQU5mcmJJZn5eUCjYgE=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Host Name" = _t, Tag = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Host Name", type text}, {"Tag", type text}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Host Name"}, {{"New", each Text.Combine([Tag], ", ")}}),
    #"Changed Type1" = Table.TransformColumnTypes(#"Grouped Rows",{{"New", type text}})
in
    #"Changed Type1"

 

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

Top Solution Authors
Top Kudoed Authors