Forum Discussion

jcastr02's avatar
jcastr02
Icon for Post Prodigy rankPost Prodigy
1 year ago

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
IDPR&A Leader.title IDPR&A Leader.title
1  1 
3Grant, Chandle 3Grant, Chandle
4  4 
5Goodrum, Kali 5Goodrum, Kali
6Goodrum, Kali 6Goodrum, Kali; Grant, Chandle
6Grant, Chandle 7Grant, Chandle
7Grant, Chandle   

5 Replies

  • 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:

     

     

     

  • 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.

  • Anonymous's avatar
    Anonymous
    Not 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

  • Anonymous's avatar
    Anonymous
    Not 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

  • Anonymous's avatar
    Anonymous
    Not 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