- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Merge multiple lines of data into one while extending data into row while merging
Good Morning,
I have an issue where I need some help. I have a list of data where I have a unique ID number for each customer. On that customer i have multiple rows of who is assigned to the account. I need to merge the multilple rows (2-5 each) into the same row using the Customer ID for reference and in theory the rest of the data to tack on at the end of the line where the previous row left off that it was merged to.
For this example each Account ID has 2 team members associated.
I would like to to read exactly how line 1 is shown but then add the information from line 2 as the Account Id matches and add the remainder of the row to the tail end (Cell E1-G1)
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Hi @AtticusZak - to achieve your outcome you need to understand the advanced feature of Table.Group. Please consider the following Advanced Group By Tricks in Power Query - YouTube. Chandeep gives good explanation. Using this approach, you will have a table with the following:
Within the Nested Table in each row, you will find the two Rows with the employee details that you want to split in Column groups. To these tables though we want to add an Table.AddIndexColumn.
We can now expand the table columns to add Employer, Job, Email, Phone and Index back to Customer.
We can now use the Unpivot and Pivot features in Power Query to transition the Columns to Rows then to separate Columns. Transpose, pivot or unpivot in Power Query? - YouTube
Here is the code I created:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcspPKlbSUfLKTwWSvolF2aklmXnpQLYjEBsqxeoglCTmAcngxJxUEM8JiI3A0kGJyRmpOcVQ7UDKvwDEcQZiYwwFeSmVSIa4ALGJUmwsAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Customer = _t, Employee = _t, Job = _t, Email = _t, Phone = _t]),
#"Grouped Rows" = Table.Group(Source, {"Customer"}, {{"Table", each Table.AddIndexColumn(_ , "Index" , 1, 1) }}),
#"Expanded Table" = Table.ExpandTableColumn(#"Grouped Rows", "Table", {"Employee", "Job", "Email", "Phone", "Index"}, {"Employee", "Job", "Email", "Phone", "Index"}),
#"Unpivoted Columns" = Table.UnpivotOtherColumns(#"Expanded Table", {"Customer", "Index"}, "Attribute", "Value"),
#"Merged Columns" = Table.CombineColumns(Table.TransformColumnTypes(#"Unpivoted Columns", {{"Index", type text}}, "en-GB"),{"Attribute", "Index"},Combiner.CombineTextByDelimiter(" ", QuoteStyle.None),"Merged"),
#"Pivoted Column" = Table.Pivot(#"Merged Columns", List.Distinct(#"Merged Columns"[Merged]), "Merged", "Value"),
#"Changed Type" = Table.TransformColumnTypes(#"Pivoted Column",{{"Employee 1", type text}, {"Job 1", type text}, {"Email 1", type text}, {"Phone 1", type text}, {"Employee 2", type text}, {"Job 2", type text}, {"Email 2", type text}, {"Phone 2", type text}})
in
#"Changed Type"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Hello Daryl.
Im looking to do something like this shown below but on a much larger scale.
Turned into
Customer being the place holder and all other rows for the same company merged/added onto the Customer line
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Hi @AtticusZak - to achieve your outcome you need to understand the advanced feature of Table.Group. Please consider the following Advanced Group By Tricks in Power Query - YouTube. Chandeep gives good explanation. Using this approach, you will have a table with the following:
Within the Nested Table in each row, you will find the two Rows with the employee details that you want to split in Column groups. To these tables though we want to add an Table.AddIndexColumn.
We can now expand the table columns to add Employer, Job, Email, Phone and Index back to Customer.
We can now use the Unpivot and Pivot features in Power Query to transition the Columns to Rows then to separate Columns. Transpose, pivot or unpivot in Power Query? - YouTube
Here is the code I created:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcspPKlbSUfLKTwWSvolF2aklmXnpQLYjEBsqxeoglCTmAcngxJxUEM8JiI3A0kGJyRmpOcVQ7UDKvwDEcQZiYwwFeSmVSIa4ALGJUmwsAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Customer = _t, Employee = _t, Job = _t, Email = _t, Phone = _t]),
#"Grouped Rows" = Table.Group(Source, {"Customer"}, {{"Table", each Table.AddIndexColumn(_ , "Index" , 1, 1) }}),
#"Expanded Table" = Table.ExpandTableColumn(#"Grouped Rows", "Table", {"Employee", "Job", "Email", "Phone", "Index"}, {"Employee", "Job", "Email", "Phone", "Index"}),
#"Unpivoted Columns" = Table.UnpivotOtherColumns(#"Expanded Table", {"Customer", "Index"}, "Attribute", "Value"),
#"Merged Columns" = Table.CombineColumns(Table.TransformColumnTypes(#"Unpivoted Columns", {{"Index", type text}}, "en-GB"),{"Attribute", "Index"},Combiner.CombineTextByDelimiter(" ", QuoteStyle.None),"Merged"),
#"Pivoted Column" = Table.Pivot(#"Merged Columns", List.Distinct(#"Merged Columns"[Merged]), "Merged", "Value"),
#"Changed Type" = Table.TransformColumnTypes(#"Pivoted Column",{{"Employee 1", type text}, {"Job 1", type text}, {"Email 1", type text}, {"Phone 1", type text}, {"Employee 2", type text}, {"Job 2", type text}, {"Email 2", type text}, {"Phone 2", type text}})
in
#"Changed Type"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Hi @AtticusZak - a couple of suggestion that might help the community help you.
(1) Could you add some sample data using the "Add Data" feature in Power BI?
(2) Could you show an example of what you think the end result might look like using Excel?
Many Thanks
Daryl

Helpful resources
Join us at the Microsoft Fabric Community Conference
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Power BI Monthly Update - February 2025
Check out the February 2025 Power BI update to learn about new features.

Subject | Author | Posted | |
---|---|---|---|
08-22-2024 09:13 AM | |||
05-31-2023 11:37 AM | |||
03-14-2024 12:04 AM | |||
02-15-2024 09:52 AM | |||
09-07-2023 11:50 PM |
User | Count |
---|---|
28 | |
27 | |
25 | |
14 | |
10 |
User | Count |
---|---|
24 | |
21 | |
17 | |
16 | |
10 |