Forum Discussion
grouping by ID
hello please see the attachment current versus the expected result. How can I achieve this in Power Query within Power BI. Note that the column PR&A Leader.title is a people picker columns
I tried to group by ID and get all rows as aggregate but stuck from there..
| Current | Expected | |||
| ID | PR&A Leader.title | ID | PR&A Leader.title | |
| 1 | 1 | |||
| 3 | Grant, Chandle | 3 | Grant, Chandle | |
| 4 | 4 | |||
| 5 | Goodrum, Kali | 5 | Goodrum, Kali | |
| 6 | Goodrum, Kali | 6 | Goodrum, Kali; Grant, Chandle | |
| 6 | Grant, Chandle | 7 | Grant, Chandle | |
| 7 | Grant, Chandle |
5 Replies
- parry2k
Super User
jcastr02 start a new blank query, click advanced editor and paste this code, follow these steps on real data.
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUVJQitWJVjIGstyLEvNKdBScMxLzUnJSwcImcAWmIAX5+SlFpbk6Ct6JOZlgUTPcopiGmWMRjgUA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ID = _t, #"PR&A Leader.title" = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"ID", Int64.Type}, {"PR&A Leader.title", type text}}), #"Grouped Rows" = Table.Group(#"Changed Type", {"ID"}, {{"All", each _, type table [ID=nullable number, #"PR&A Leader.title"=nullable text]}}), #"Added PR&A Leader.title" = Table.AddColumn(#"Grouped Rows", "PR&A Leader.title", each Lines.ToText([All][#"PR&A Leader.title"],if Table.RowCount([All]) > 1 then ";" else ""), type text), #"Removed Columns" = Table.RemoveColumns(#"Added PR&A Leader.title",{"All"}) in #"Removed Columns"output:
- Ashish_Mathur
Super User
Hi,
This M code works
let Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content], #"Grouped Rows" = Table.Group(Source, {"ID"}, {{"Count", each Text.Combine([#"PR&A Leader.title"],","), type nullable text}}) in #"Grouped Rows"Hope this helps.
- AnonymousNot applicable
Hi jcastr02,
Just following up to check if the solution shared by our Super User helped resolve your issue. If you're still facing difficulties or need further assistance, please let us know — we’re here to help!
If the response addressed your query, we kindly request you to mark it as Accepted Solution and click Yes if you found it helpful. This supports others in the community as well.
Best regards,
Prasanna Kumar
- AnonymousNot applicable
Hi jcastr02,
We wanted to kindly check in to see if everything is working as expected after trying the suggested solution. If there’s anything else we can assist with, please don’t hesitate to ask.
If the issue is resolved, we’d appreciate it if you could mark the helpful reply as Accepted Solution — it helps others who might face a similar issue.
Warm regards,
Prasanna Kumar
- AnonymousNot applicable
Hi jcastr02,
Just a gentle reminder — has your issue been resolved? If so, we’d be grateful if you could mark the solution that worked as Accepted Solution, or feel free to share your own if you found a different fix.
This not only closes the loop on your query but also helps others in the community solve similar issues faster.
Thank you for your time and feedback!
Best,
Prasanna Kumar