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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Syndicate_Admin
Administrator
Administrator

How to replace text in a comma separated column with new value

I need to replace the original column text values with the New ID.  I need to maintain the commas. 

 

Original Column 

 

contract_communities_list
Avalon Wilton on River Rd (CT005), Avalon New Canaan (CT014), Avalon Darien (CT017), Avalon Norwalk Retail (CT021)
Avalon East NorwalkSOLD (CT026), Avalon New Canaan (CT014), Avalon NorwalkSOLD (CT022), Avalon Wilton on DanburySOLD (CT024)
Avalon East NorwalkSOLD (CT026), Avalon New Canaan (CT014), Avalon Wilton on River Rd (CT005), Avalon Norwalk Retail (CT021)
Avalon East NorwalkSOLD (CT026), Avalon New Canaan (CT014), Avalon Wilton on River Rd (CT005), Avalon Norwalk Retail (CT021)
AVA DoBro (NY037), Avalon Clinton North (NY533), Avalon Clinton South (NY534), AVA Fort Greene (NY026), Avalon MamaroneckSOLD (NY006), Avalon Midtown West (NY525), Avalon Morningside Park (NY823), Avalon OssiningSOLD (NY035), Avalon Riverview (NY011), Avalon Riverview North (NY018), Avalon West Chelsea (NY829), Avalon White Plains (NY022), Avalon Willoughby Square (NY039), Avalon Yonkers (NY047), Avalon Bowery Place II - JV (NY821), Avalon Green ISOLD (NY003), Avalon Green IISOLD (NY032), Avalon Green IIISOLD (NY038), AVA High Line (NY834), Avalon Bowery Place I (NY815)

 

Reference Data to use for replacement

 

ReferenceNew ID
eaves Quincy (MA003)MA003 eaves Quincy
Avalon at The Pinehills (MA016)MA016 Avalon at The Pinehills
Avalon at the Hingham Shipyard (MA027)MA027 Avalon at the Hingham Shipyard
Avalon Northborough (MA030)MA030 Avalon Northborough
Avalon Northborough II (MA032)MA032 Avalon Northborough II
Avalon at The Pinehills II (MA033)MA033 Avalon at The Pinehills II
Avalon Natick (MA037)MA037 Avalon Natick
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi vbowlen

 

Here is my solution. Add a custom column with below code. ReferenceDataTable is another table which has two columns "Reference" and "New ID", just like you have shown. Please notice that the first column should have old values and the second column should have new values. 

 

= Text.Combine(List.ReplaceMatchingItems(List.Transform(Text.Split([contract_communities_list], ","), Text.Trim), Table.ToRows(ReferenceDataTable)), ", ")

 

vjingzhanmsft_1-1704448763167.png

 

Here is a blog for your reference: Replace Values in Power Query M (Ultimate Guide) - BI Gorilla

 

Best Regards,
Jing
If this post helps, please Accept it as Solution to help other members find it. Appreciate your Kudos!

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi vbowlen

 

Here is my solution. Add a custom column with below code. ReferenceDataTable is another table which has two columns "Reference" and "New ID", just like you have shown. Please notice that the first column should have old values and the second column should have new values. 

 

= Text.Combine(List.ReplaceMatchingItems(List.Transform(Text.Split([contract_communities_list], ","), Text.Trim), Table.ToRows(ReferenceDataTable)), ", ")

 

vjingzhanmsft_1-1704448763167.png

 

Here is a blog for your reference: Replace Values in Power Query M (Ultimate Guide) - BI Gorilla

 

Best Regards,
Jing
If this post helps, please Accept it as Solution to help other members find it. Appreciate your Kudos!

Syndicate_Admin
Administrator
Administrator

I have over 300 + new id's.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors