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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
BENJO
Regular Visitor

Persons in the same team

Hi all,

 

I have a table with two columns. In the first column are names and in the second column the corresponding team.

I would like a third column in which all teammates in the same team are listed. How can I make it so that there is one row per name with all teammates?

2024-03-23_20h58_35.png

 

Solution for BerLIN: autumn,AAAAY, Lysoar, Life

Solution for autumn: BerLIN,AAAAY,Lysoar,Life

 

 

Thanks and best regards

 

 

5 REPLIES 5
dufoq3
Super User
Super User

Hi @BENJO,

 

check every single step, maybe you want one of the middle steps as result

 

Final reslut

dufoq3_1-1711277301433.png

 

v1

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("jc9BCsIwEIXhq5SsLPQScSGIIRZbBFu6iHGkselEmwRsT29x52bibP+PB9O2bBextNFnZe8AzTvbnLk4nrisc1awLUxiL1lXJJyKIY6Ydny9S5qJ2Ts1/eHMHb6qAgwGwfrf3oC13niK1IAL1R+ux1egxJNLrW6KIpXSM9UXGAZAcsHoA7ngxuv6Z/cB", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Team = _t, Name = _t]),
    GroupedRows = Table.Group(Source, {"Team"}, {{"Names", each Text.Combine([Name], ", "), type table}, {"All", each _, type table}}),
    ExpandedAll = Table.ExpandTableColumn(GroupedRows, "All", {"Name"}, {"Name"}),
    RemovedName = Table.ReplaceValue(ExpandedAll,
        each [Names], 
        each [Name],
        (x,y,z)=> Text.Combine(List.Select(Text.Split(y, ", "), each _ <> z), ", "),
        {"Names"} )
in
    RemovedName

 

 

v2

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("jc9BCsIwEIXhq5SsLPQScSGIIRZbBFu6iHGkselEmwRsT29x52bibP+PB9O2bBextNFnZe8AzTvbnLk4nrisc1awLUxiL1lXJJyKIY6Ydny9S5qJ2Ts1/eHMHb6qAgwGwfrf3oC13niK1IAL1R+ux1egxJNLrW6KIpXSM9UXGAZAcsHoA7ngxuv6Z/cB", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Team = _t, Name = _t]),
    GroupedRows = Table.Group(Source, {"Team"}, {{"NameList", each [Name], type list}, {"All", each _, type table}}),
    ExpandedAll = Table.ExpandTableColumn(GroupedRows, "All", {"Name"}),
    Ad_Names = Table.AddColumn(ExpandedAll, "Names", each Text.Combine(List.Select([NameList], (x)=> x <> [Name]), ", "), type text),
    RemovedColumns = Table.RemoveColumns(Ad_Names,{"NameList"})
in
    RemovedColumns

Note: Check this link to learn how to use my query.
Check this link if you don't know how to provide sample data.

AnalyticPulse
Super User
Super User

Let's assume your table is called "Teammates" with columns "Name" and "Team". You want to add a calculated column named "Teammates List" that lists all teammates in the same team.
create a calculated column as below:
Teammates List =
VAR CurrentTeam = Teammates[Team]
RETURN
CONCATENATEX (
FILTER ( Teammates, Teammates[Team] = CurrentTeam ),
Teammates[Name],
", "
)

If this helped, Follow this blog for more insightful information about data analytics
https://analyticpulse.blogspot.com/
Please Subscribe AnalyticPulse on YouTube for future updates:
https://www.youtube.com/@AnalyticPulse
Please subscribe CogniJourney On Youtube For Daily fun facts:
https://www.youtube.com/@CogniJourney


Hey AnalyticPulse,

 

thanks for the quick response.

What do you mean with calculated column? Custom Column? I get an error here

 

2024-03-23_20h57_22.png

2024-03-23_20h58_35.png

Solution for BerLIN: autumn,AAAAY, Lysoar, Life

Solution for autumn: BerLIN,AAAAY,Lysoar,Life

calculated columns means the on eyou add in data view mode from data modeling tab, not inn power query

2024-03-24_09h00_18.png

Thanks, that worked. But I want the Name in the row to not be in the Teammates List. Is that possible?

I also would like to do it within the power query editor, is that possible aswell?

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.