Forum Discussion
cgkas
Helper V
7 years agoRename 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...
- 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
d_gosbell
Super User
7 years agoTry 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