Forum Discussion

Rygar's avatar
Rygar
Helper II
2 years ago
Solved

Naming existing Columns 1 to N

Hello!   for Example, in a six Column table I would like to name these Columns from 1 to 6 or from c1 to c6 or something like that. I can not use rename (old name=>new name), because I have multip...
  • AlexisOlson's avatar
    2 years ago

    I think you can do a dynamic rename using Table.ColumnNames.

     

    For example,

    let
        Source = Table.FromRows({{"a","b","c","d","e"}}),
        CurrentColumnNames = Table.ColumnNames(Source),
        NewColumnNames = List.Transform({1..List.Count(CurrentColumnNames)}, Number.ToText),
        #"Renamed Columns" = Table.RenameColumns(Source, List.Zip({CurrentColumnNames, NewColumnNames}))
    in
        #"Renamed Columns"