Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
9 years ago
Solved

Change column header names in Power Query

Hi,

 

Trying to change a column header names using Power Query.

 

The issue is that as I am doing this to multiple imports the column title isn't "fixed" it is the default "ColumnNN" and it could be any number for "NN". The column headers are the first and last column.

 

Thanks,

Andrew

  • Anonymous's avatar
    Anonymous
    9 years ago

    Ok no worries.  My quick napkin attempt would be something like:

     

    #"Renamed Columns" = Table.RenameColumns(#"Name_of_your_previous_step",{{List.Last(Table.ColumnNames(Name_of_your_previous_step), "RenamedName"}})

     

6 Replies

  • Hi Anonymous

     

    Just so that I understand you have a variable number of columns that are in your source file.

     

    With that being said they are always the first and last columns that will need to be renamed?

    And what is that renaming based on?

      • Anonymous's avatar
        Anonymous
        Not applicable

        Hi Anonymous,

         

        Yes that was mine as well but it achieved what I wanted to achieve with removing columns but I've tried using it to do rename and unfortuantely my PQ is not good enough to actually effect the change.

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi GilbertQ,

       

      Thanks for the reply.

       

      Yes it is just the first and last columns where the intervening columns can be variable in number (there is actually one for each day of a month and the sheets are by month).

       

      Column name change is a constant of "Month" and "Booked".