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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Homaa
Frequent Visitor

How to rename a duplicated value in a column?

there is a table that has two columns (id, name). there is a value in "name" column as "ABC Kitchen" which has two separate _ids but the same name. I want to change the name for the one that _id is "12345" to "ABC Kitchen (old)".
I tried to add a step to replace value

 

= Table.ReplaceValue(#"PreviousStepName", "ABC Kitchen (old)", each if [id] = "12345" then "ABC Kitchen (old)" else [name], Replacer.ReplaceText,{"name"})

 

but it didn't change the name. I also tried this

 

= Table.TransformColumns(#"PreviousStepName", {{"name", each if [id] = "12345" then "ABC Kitchen (old)" else _, Text.Type}})

 

but this time, I got error for all values in the column. Do you have any suggestion for me?

1 ACCEPTED SOLUTION

@Homaa 

Then, change the sentence by this one. It was my fault when writing it:

 

 

= Table.ReplaceValue(PreviousStepName,each [Name], each if [ID]="12345" then "ABC Kitchen (Old)" else [Name] ,Replacer.ReplaceText,{"Name"})

 

View solution in original post

4 REPLIES 4
Homaa
Frequent Visitor

Thank you but the problem here is that there are other values in the "name" column as well. So, [ID] <> "12345" is not working. the type for both column is text

@Homaa 

Then, change the sentence by this one. It was my fault when writing it:

 

 

= Table.ReplaceValue(PreviousStepName,each [Name], each if [ID]="12345" then "ABC Kitchen (Old)" else [Name] ,Replacer.ReplaceText,{"Name"})

 

Homaa
Frequent Visitor

it works. Thank you!

mlsx4
Super User
Super User

Hi @Homaa 

= Table.ReplaceValue(PreviousStepName,each [Name], each if [ID]<>"12345" then "ABC Kitchen" else "ABC Kitchen (Old)",Replacer.ReplaceText,{"Name"})

Be careful with the type of data for the column id too.  Because if it is number, you should compare without "" characters

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors
Top Kudoed Authors