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.
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?
Solved! Go to Solution.
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"})
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
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"})
it works. Thank you!
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
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.