Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Rename multiple column names along with split words

I have a table imported into Power Query editor. The columns have the following names:

accountid| accountcode| customersizecode| preferredcontact

--------------------------------------------------------------------

1234        | wdkdf           | abdef                     | dksdmsd

1092        | kjfgfkf           | hghg                      |opwkffkd

1342        | isivmw          | wlslvs                      | wyywcga

 I am trying to rename the columns with splited words to it's corresponding phrase. e.g. :
Account Id | Account Code | Customersize Code | Preferred Contact ....

 

I tried 

 Table.TransformColumnNames

 but it doesn't work.

 

Any idea on split the word?

Thanks!

@ImkeF

  • Oops.  Over thought it.  You will need to hardcode it manually, I think.  Just double click on each column header and type in the desired column name.  This should result in a single step that renames multiple columns.

    Regards,

    Pat

  • Hi Anonymous ,

    Seems that you have not specific split definition for multiple columns like "_", " " etc. so the directly way to rename columns is that renaming them manually which is like @ mahoneypat mentioend.

    If your columns have the same split defintion, you can follow this similar issue to rename them:

    Rename multiple column names along with changing their column numbers to Letters 

     

    Best Regards,
    Community Support Team _ Yingjie Li
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

4 Replies

  • mahoneypat's avatar
    mahoneypat
    Microsoft Employee

    Oops.  Over thought it.  You will need to hardcode it manually, I think.  Just double click on each column header and type in the desired column name.  This should result in a single step that renames multiple columns.

    Regards,

    Pat

  • v-yingjl's avatar
    v-yingjl
    Community Support

    Hi Anonymous ,

    Seems that you have not specific split definition for multiple columns like "_", " " etc. so the directly way to rename columns is that renaming them manually which is like @ mahoneypat mentioend.

    If your columns have the same split defintion, you can follow this similar issue to rename them:

    Rename multiple column names along with changing their column numbers to Letters 

     

    Best Regards,
    Community Support Team _ Yingjie Li
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

  • mahoneypat's avatar
    mahoneypat
    Microsoft Employee

    Not sure what your input data looks like.  Hopefully you could split your columns by "|" to avoid having to remove it.  If not, a step with this formula with will remove "|" from all column names.  You can rename one column to generate most of the code needed, and then copy/paste the List.Zip part over the same part of that.

     

    = Table.RenameColumns(#"Changed Type", List.Zip({Table.ColumnNames(#"Changed Type"), List.Transform(Table.ColumnNames(#"Changed Type"), each Text.Replace(_, "|",""))}))

     

    Regards,

    Pat

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thanks for the anwering!  "|" just mean different columns, LOL. What I really want is to rename multiple columns name from "accountid" to "Account ID", "accountcode" to "Account Code"...

      The hard part is there is no delimiter to split the text.