Forum Discussion

teylyn's avatar
teylyn
Advocate III
5 years ago
Solved

M 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...
  • wdx223_Daniel's avatar
    5 years ago

    Table.RenameColumns(Navigation,List.Transform(Table.ColumnNames(Navigation),each {_,Text.Replace(_,"_"," ")}))

  • ImkeF's avatar
    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(_, "_", " ") )