Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Remove certain words from text column using column2

remove certain strings from the column Input Input output Hi I am having issue with this product am Hi I having issue with this product Error product live Monday dumm cool cool Error ...
  • ronrsnfld's avatar
    4 years ago

    You can leverage the List.ReplaceMatchingItems function with Table.AddColumn.

     

    Words to Remove

    let
    
    //Read in original data
        Source = Excel.CurrentWorkbook(){[Name="InputData"]}[Content],
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"Input", type text}}),
    
    //Read in list of words to remove
        Source2 = Excel.CurrentWorkbook(){[Name="removeWords"]}[Content],
        RemoveWords = Source2[Input],
    
    //Add column with the words to remove replace by null
        #"Remove Words" = 
            Table.AddColumn(#"Changed Type", "Output", 
                each Text.Combine(
                        List.ReplaceMatchingItems(
                            Text.Split([Input]," "), 
                            List.Transform(RemoveWords, each {_, null})),
                     " "))
    in
      #"Remove Words"