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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

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

Top Solution Authors
Top Kudoed Authors