Multiple Replacement Entire Cell Content Matching Specific Text

absherzad

New Member
Joined
Jun 19, 2017
Messages
42
Hi everyone,

I want to customize Ivan Bondarenko's custom function to replace the entire cell content containing specified text, for instance, using the Text.Contains() function.
It however, seems the provided replacer functions supported by the Table.ReplaceValue() function are Text.Replace() or Value.Replace().

  • Do you think it is a good idea and efficient to create a new conditional column using the Text.Contains() function in your custom function and how?
  • To keep the performance in mind, it is worth it to mention that I want to apply this function on 4 separate columns, each includes duplicate instances. The idea crossed my mind is to create 4 reference from original query and then perform the remove duplicates transformation on each of the referenced query individually. Finally use the merge transformation feature to join them back together. What do you think of this approach?

I tried with the following customization but did not work out:
Code:
let
  ReplaceAll = (InputTable as table, ColumnName as text, ReplacementTable as table, optional StartRow as number) =>
let
   ActualRow = if (StartRow =null) then 0 else StartRow,
   //result  = Table.ReplaceValue(InputTable, ReplacementTable{ActualRow}[Original Text], ReplacementTable{ActualRow}[New Text] ,Replacer.ReplaceText, {ColumnName}),
   result = Table.AddColumn(InputTable, "Custom", if Text.Contains({ColumnName}, ReplacementTable{ActualRow}[Original Text]) then ReplacementTable{ActualRow}[New Text] else null ),


   NextRow = ActualRow + 1,
   
   OutputTable = if NextRow > (Table.RowCount(ReplacementTable)-1)
     then result
     else
       @ReplaceAll(result, ColumnName, ReplacementTable, NextRow)
in
    OutputTable
in 
ReplaceAll

Thank you,
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.

Forum statistics

Threads
1,215,455
Messages
6,124,935
Members
449,195
Latest member
Stevenciu

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top