Forum Discussion

TeeGee's avatar
TeeGee
Helper II
6 years ago
Solved

Simpler way to write M code to rename multiple columns by position? (user defined global function?)

I am importing multiple spreadsheets with different languages, so am having to hardcode my columns names by ordinal position in the M code. I find the syntax below hard to read and even harder to wr...
  • SteveCampbell's avatar
    6 years ago

    You could do it all in one step, for example:

     Table.RenameColumns(rename00,{  {Table.ColumnNames(rename00){1}, "CBF ID"}, {Table.ColumnNames(rename00){2}, "CBF Description"},
    {Table.ColumnNames(rename00){3}, "RTO Recovery TIME Objective"}.... }),

    Notice each rename is wrapped in {} and seperated by commas, but then the total step is wrapped in the red {}

     

     

    Appreciate your Kudos
    I love to share - connect with me!

    Stay up to date on  
    Read my blogs on