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! Learn more

Reply
wad11656
Advocate I
Advocate I

New column with concatenated values based on 2 matching IDs

In Power Query, How can I create a new column that combines the values from 1 column, if the values in 2 columns match?

 

In this case, how can I concatenate Contact_Type values when the Contact_ID and Order_ID match?

 

(I prefer not to use Grouping and having to worry about managing all the rest of my columns, ex. the Dummy_Data column)

 

Order_IDContact_IDContact_TypeContact_NameDummy_Data
(Don't mess with me)
14SHIPPINGMegan1234
14BILLINGMegan1234
212SHIPPINGPete1234
217BILLINGRob1234
34SHIPPINGMegan1234
312BILLINGPete1234

 

vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv

 

Order_IDContact_IDContact_TypeContact_NameDummy_Data
(Don't mess with me)
Contact_Type-mod
14SHIPPINGMegan1234SHIPPING & BILLING
14BILLINGMegan1234SHIPPING & BILLING
212SHIPPINGPete1234SHIPPING
217BILLINGRob1234BILLING
34SHIPPINGMegan1234SHIPPING
312BILLINGPete1234BILLING
1 ACCEPTED SOLUTION
latimeria
Solution Specialist
Solution Specialist

Hi @wad11656 ,

Try this, using grouping but and you don't have to worry for the remaning columns (you cen even add columns without changing the code:

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8i9KSS2K93RR0lFyzs8rSUwuQeWEVBakInH9EnNBXJfS3NzKeJfEkkSlWJ1oJUOgkAkQB3t4BgR4+rkDmb6p6Yl5QNrQyNgERY2Tp48PDiVGYA6qOQGpJakYasxRzAnKT0JWYUyEY4xhNiFMQbEoFgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t, Column2 = _t, Column3 = _t, Column4 = _t, Column5 = _t]),
    #"Promoted Headers" = Table.PromoteHeaders(Source, [PromoteAllScalars=true]),
    #"Grouped Rows" = Table.Group(#"Promoted Headers", {"Order_ID", "Contact_ID"}, {{"Rows", each _, type table [Order_ID=nullable text, Contact_ID=nullable text, Contact_Type=nullable text, Contact_Name=nullable text, Dummy_Data=nullable text]}}),
    Custom1 = Table.TransformColumns(#"Grouped Rows",{{"Rows", (Group)=> Table.AddColumn(Group, "Contact_Type-mod", each Text.Combine(Group[Contact_Type], " & "))}}),
    Custom2 = Table.Combine(Custom1[Rows])
in
    Custom2

 

latimeria_0-1664542066462.png

 

View solution in original post

3 REPLIES 3
latimeria
Solution Specialist
Solution Specialist

Hi @wad11656 ,

Try this, using grouping but and you don't have to worry for the remaning columns (you cen even add columns without changing the code:

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8i9KSS2K93RR0lFyzs8rSUwuQeWEVBakInH9EnNBXJfS3NzKeJfEkkSlWJ1oJUOgkAkQB3t4BgR4+rkDmb6p6Yl5QNrQyNgERY2Tp48PDiVGYA6qOQGpJakYasxRzAnKT0JWYUyEY4xhNiFMQbEoFgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t, Column2 = _t, Column3 = _t, Column4 = _t, Column5 = _t]),
    #"Promoted Headers" = Table.PromoteHeaders(Source, [PromoteAllScalars=true]),
    #"Grouped Rows" = Table.Group(#"Promoted Headers", {"Order_ID", "Contact_ID"}, {{"Rows", each _, type table [Order_ID=nullable text, Contact_ID=nullable text, Contact_Type=nullable text, Contact_Name=nullable text, Dummy_Data=nullable text]}}),
    Custom1 = Table.TransformColumns(#"Grouped Rows",{{"Rows", (Group)=> Table.AddColumn(Group, "Contact_Type-mod", each Text.Combine(Group[Contact_Type], " & "))}}),
    Custom2 = Table.Combine(Custom1[Rows])
in
    Custom2

 

latimeria_0-1664542066462.png

 

Thank you - that seemed to have worked great.

 

Unfortunately another reason I don't like Grouping is because each time I implement a new Grouping, it seemingly adds 30 minutes to 1hr of report loading time. So now I am stuck waiting forever for my data. Microsoft should optomize their grouping algorithm.

_AlexandreRM_
Helper II
Helper II

Hello @wad11656 , you should use groupping and joining.

1st step : group your table on Contact_ID and Order_ID (the thing you didn't wanted to do),

2nd step : join the the groupping step with the step before groupping (to achieve that, you will need to edit manually the code). Then, expand it to retrieve the group step result in the Contact_Type-mod.

Helpful resources

Announcements
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!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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 Kudoed Authors