Forum Discussion
M Code to replace underscores in column names
- 5 years ago
Table.RenameColumns(Navigation,List.Transform(Table.ColumnNames(Navigation),each {_,Text.Replace(_,"_"," ")}))
- 5 years ago
Hi teylyn and wdx223_Daniel ,
I've been there as well before I've discovered that the M-language has some nice functions that are not exposed through the UI. Transforming column names with a custom function is one of them:Table.TransformColumnNames(Source, each Text.Replace(_, "_", " ") )
Table.RenameColumns(Navigation,List.Transform(Table.ColumnNames(Navigation),each {_,Text.Replace(_,"_"," ")}))
Hi, this solution does not work instead it gives follwing error
Expression.SyntaxError: Token Eof expected.
- Rustickoff3 years agoNew Member
Please kindly change Navigation with the name of previous step/table name and replace with Text.Replace(_," ","_") if you want to replace space with _
- Rustickoff3 years agoNew Member
I use the following to make it fit for sql:
TextLower = Table.TransformColumnNames(PreviousStepTableName, Text.Lower),LowerDash = Table.RenameColumns( TextLower, List.Transform(Table.ColumnNames(TextLower), each {_, Text.Replace(_," ","_")}), MissingField.Ignore)