Forum Discussion

cgkas's avatar
cgkas
Helper V
7 years ago
Solved

Rename all column headers removing certain text

Hello to all,   I want to remove some text ("ABC.XYZ_") from all column headers.   The code I have so far is like this but for the List of second step I get error. let Source = Table.FromRow...
  • d_gosbell's avatar
    7 years ago

    Try changing the Text.Remove to Text.Replace and replace with an empty string

     

    eg.

     

    let
        Source = Table.FromRows({{1,2,3,4}},{"ABC.XYZ_4_NB.5", "ABC.XYZ_2_NB.9","ABC.XYZ_7_NB.3", "ABC.XYZ_K_MJ.3"}),
        RenameHeaders = List.Transform(Table.ColumnNames(Source), each {_, Text.Replace(_,"ABC.XYZ_","")}),
        Output = Table.RenameColumns(Source, RenameHeaders)
    in
        Output