Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago

Remove text in string from a separate table

Hi,

 

I have a table with a column of data that has a string of text. I have another table with a list of words i want to remove from that column.

These 2 tables have no relationship as obviously there is nothing that can be joined between the 2.

 

The code i have should put everything into lists based on delimiters and then remove any matching words, but it doesn't.

 

It does put the 'string' column into lists but seems to error when attempting to remove words from the table with words to remove in.

 

 

 

 

= let
Source = #"Renamed Columns2",   
Delimiters = Text.ToList(" ,':;,.!?"),  
ReplacementList = List.Transform(WordsToRemove[WordsToRemove]),
SplittedText = Table.AddColumn(Source, "RemoveWords", each Splitter.SplitTextByAnyDelimiter(Delimiters)([String]), type {text}),
ReplacedWords = Table.AddColumn(SplittedText,"Replaced Words", each List.ReplaceMatchingItems([RemoveWords],ReplacementList,Comparer.OrdinalIgnoreCase), type {text})
in
ReplacedWords

 

 

 

 

I've been playing a lot with it and can't seem to figure it out.

This is the error i get on the Replaced Words part:

Expression.Error: 1 arguments were passed to a function which expects 2.
Details:
Pattern=
Arguments=[List]

 

Any suggestions would be great.

 

Thanks.

1 Reply

  • v-kelly-msft's avatar
    v-kelly-msft
    Community Support

    Hi  Anonymous ,

     

    Do the characters which need to be removed is one by one corresponding to another table,will such occation happen when a certain string exists in more than 1 row?And we need to remove it in all rows?

    Can you take some examples to make your requirement more clear.

     

     

    Best Regards,
    Kelly

    Did I answer your question? Mark my post as a solution!