Help with ReplaceValue and Replacer.ReplaceText

a68tbird
Posts: 32
Joined: Sat Mar 19, 2016 4:58 am
Location: Toronto, ON

Help with ReplaceValue and Replacer.ReplaceText

Postby a68tbird » Sat Feb 11, 2017 7:49 am

Hello All -
I'd like to replace the text value of column2 based on the value found in column1. I'm inserting a custom step in my query, and I thought about the following, but didn't work:

= Table.ReplaceValue(#"PreviousStep","12345",each _[column2] ="NewProductName",Replacer.ReplaceText,{"column1"})

where "12345" is the value to match.

I don't get any errors, but it doesn't replace the value in column2 for that particular row.

Any help?

Thanks!
Travis

User avatar
AndVGri
Posts: 18
Joined: Thu Jun 02, 2016 2:41 am
Location: Sankt-Peterburg

Re: Help with ReplaceValue and Replacer.ReplaceText

Postby AndVGri » Sat Feb 11, 2017 10:01 pm

Hello.
You try to combine filter and replace functions in one. You need execute some steps for a solve of your task.
I think it is better to do with an additional column. If I understood you rightly.

Code: Select all

newCol2 = Table.AddColumn(#"PreviousStep", "newCol2", each if [column1] = "12345" then [column2] = "NewProductName" else [column2], type text),
delOldCol2 = Table.RemoveColumns(newCol2, {"column2"}),
resetCol2name = Table.RenameColumns(delOldCol2, { {"newCol2", "column2"} })

Regards,

a68tbird
Posts: 32
Joined: Sat Mar 19, 2016 4:58 am
Location: Toronto, ON

Re: Help with ReplaceValue and Replacer.ReplaceText

Postby a68tbird » Tue Feb 14, 2017 2:31 am

Thanks. I wonder though if this wouldn't be a big performance inhibitor. If I had a million plus rows in my table, and only 1 or 2 rows matched my criteria, we're copying an entire column and then deleting a column just to change those couple of values.


Return to “Power Query”

Who is online

Users browsing this forum: No registered users and 1 guest