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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
shaebert
Helper III
Helper III

Need Help Grouping and Combining Rows

Hello, I have a table of data that I need help transforming. Below is a before/after example. 

 

Before:

 

Campaign    ContactURL
1Joe Smithgoogle.com
1Joe Smithyahoo.com
1Jerry Wilsongoogle.com
2Jerry Wilsongoogle.com
2Jerry Wilsonyahoo.com
2Jerry Wilson      msn.com

 

After

 

Campaign  NameURL
1Joe Smithgoogle.com, yahoo.com
1Jerry Wilson  google.com
2Jerry Wilson  google.com, yahoo.com, msn.com  

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @shaebert ,

Please try below steps:

1. below is my test table

Table:

vbinbinyumsft_0-1678861606376.png

2. Please try to create a new table with below dax formula:

Table2 =
VAR tmp =
    SUMMARIZE ( 'Table', [Campaign], [Contact] )
RETURN
    ADDCOLUMNS ( tmp, "URL", CALCULATE ( CONCATENATEX ( 'Table', [URL] & "," ) ) )

 

vbinbinyumsft_1-1678861647818.png

Please refer the attached .pbix file.

 

Best regards,
Community Support Team_Binbin Yu
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
Anonymous
Not applicable

Hi @shaebert ,

Please try below steps:

1. below is my test table

Table:

vbinbinyumsft_0-1678861606376.png

2. Please try to create a new table with below dax formula:

Table2 =
VAR tmp =
    SUMMARIZE ( 'Table', [Campaign], [Contact] )
RETURN
    ADDCOLUMNS ( tmp, "URL", CALCULATE ( CONCATENATEX ( 'Table', [URL] & "," ) ) )

 

vbinbinyumsft_1-1678861647818.png

Please refer the attached .pbix file.

 

Best regards,
Community Support Team_Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Ashish_Mathur
Super User
Super User

Hi,

This M code works

let
    Source = Excel.CurrentWorkbook(){[Name="Data"]}[Content],
    #"Merged Columns" = Table.CombineColumns(Table.TransformColumnTypes(Source, {{"Campaign", type text}}, "en-IN"),{"Campaign", "Contact"},Combiner.CombineTextByDelimiter(";", QuoteStyle.None),"Merged"),
    Partition = Table.Group(#"Merged Columns", {"Merged"}, {{"Partition", each Table.AddIndexColumn(_, "Index",1,1), type table}}),
    #"Expanded Partition" = Table.ExpandTableColumn(Partition, "Partition", {"URL", "Index"}, {"URL", "Index"}),
    #"Added Prefix" = Table.TransformColumns(#"Expanded Partition", {{"Index", each "URL " & Text.From(_, "en-IN"), type text}}),
    #"Split Column by Delimiter" = Table.SplitColumn(#"Added Prefix", "Merged", Splitter.SplitTextByDelimiter(";", QuoteStyle.Csv), {"Campaign", "Contact"}),
    #"Pivoted Column" = Table.Pivot(#"Split Column by Delimiter", List.Distinct(#"Split Column by Delimiter"[Index]), "Index", "URL")
in
    #"Pivoted Column"

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.