Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

rename columns

Hello,   I have 14 dimension tables, and each table contains between 10 and 20 columns. After importing the tables from my database, the columns were named as:  source_dim_name_of_table. name of c...
  • jennratten's avatar
    4 years ago

    Hello - it would be best to do this in Power Query.  You can do this by adding a new step to each table and use the Table.TransformColumnNames function, like this:

     

    RenameColumns = Table.TransformColumnNames ( Source, each Text.AfterDelimiter ( _, "." ) )

     

    Here is the full sample table with script:

     

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSAeJYnWglIyDLCMwyBrKMlWJjAQ==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [source_dim.Test1 = _t, source_dim.test2 = _t]),
        RenameColumns = Table.TransformColumnNames ( Source, each Text.AfterDelimiter ( _, "." ) )
    in
        RenameColumns

     

    BEFORE

     

    AFTER