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

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"

Forum statistics

Threads
1,223,240
Messages
6,170,951
Members
452,368
Latest member
jayp2104

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