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
thecoolcracker
Regular Visitor

Lookup and Concatenate

Hello, I'm new to Power BI and looking for a solution for my scenario below:

 

I have a SharePoint field that has multiple values in one column. This is in the form of an ID. I call this Table A

 

User_ID
12, 96, 42
1
12, 22

I have an user information list that corresponds to each of these IDs: I call this Table B

 

IDName
1Tom
12John
15David
22Julie
42Heather
96Adam
100Stacy

 

I'm looking for an output on a column in Table A like the below:

 

IDName
12, 96, 42John; Adam; Heather
1Tom
12, 22John; Julie

 

I tried different options, but couldn't succeed. I have several columns on Table A that I need to accomplish this. 

 

Please help

 

Jimbob

2 ACCEPTED SOLUTIONS
ryan_mayu
Super User
Super User

@thecoolcracker 

@vicky_ 's solution is great. Just add another solution for the last step.

you can group by in the PQ

= Table.Group(#"Expanded Table B", {"Index"}, {{"id", each Text.Combine([User_ID],","), type nullable text}, {"name", each Text.Combine([Name],","), type nullable text}})

 

then delete the index column

 

11.PNG

 

pls see the attachment below

 

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

Ashish_Mathur
Super User
Super User

Hi,

This M code works

let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"User_ID", type text}}),
    Custom1 = Table.ToRows(Table2),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each Text.Combine(List.ReplaceMatchingItems(Text.Split([User_ID],", "),Custom1),", ")),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"User_ID"})
in
    #"Removed Columns"

Hope this helps.

Ashish_Mathur_0-1713918892855.png

 


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

View solution in original post

4 REPLIES 4
Ashish_Mathur
Super User
Super User

Hi,

This M code works

let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"User_ID", type text}}),
    Custom1 = Table.ToRows(Table2),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each Text.Combine(List.ReplaceMatchingItems(Text.Split([User_ID],", "),Custom1),", ")),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"User_ID"})
in
    #"Removed Columns"

Hope this helps.

Ashish_Mathur_0-1713918892855.png

 


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

Thank you for the prompt response. I will try both options.

ryan_mayu
Super User
Super User

@thecoolcracker 

@vicky_ 's solution is great. Just add another solution for the last step.

you can group by in the PQ

= Table.Group(#"Expanded Table B", {"Index"}, {{"id", each Text.Combine([User_ID],","), type nullable text}, {"name", each Text.Combine([Name],","), type nullable text}})

 

then delete the index column

 

11.PNG

 

pls see the attachment below

 

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




vicky_
Super User
Super User

I would recommend that you fix the data in the IDs table in PowerQuery first.

 

First, I add a column for the group (so that i know which UserIds are grouped together later) - which can be done by going to Add Column > Index Column.

 

Then I split the UserIds in Transform > Split Column > by Delimiter

 

Lastly, I select all the newly created userId columns and then go to Transform > Unpivot Columns (I can also delete the attribute column since I don't need that). The result is the below table

vicky__1-1713825029327.png

After loading back in the data, create a relationship (with both cross-filter direction) between the two UserID columns. Then I can then use the following DAX in a measure to get your output:

 

Names (concatenated) = CONCATENATEX(Names, Names[Name], ", ")

vicky__2-1713825414169.png

 

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.

Top Solution Authors
Top Kudoed Authors