Forum Discussion
teylyn
Advocate III
5 years agoM Code to replace underscores in column names
Hi all, my SQL Server DBA tells me that SQL doesn't like spaces in column names, and all tables and views in that project have unsightly underscores. In Power BI, I want to replace them with blan...
- 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(_, "_", " ") )
wdx223_Daniel
Community Champion
5 years agoTable.RenameColumns(Navigation,List.Transform(Table.ColumnNames(Navigation),each {_,Text.Replace(_,"_"," ")}))
Rustickoff
3 years agoNew Member
Works perfect! Thanks a lot!
Note: change Navigation with the name of previous step/table name and replace with Text.Replace(_," ","_") if you want to replace space with _