Forum Discussion
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
- Anonymous9 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
- GilbertQSuper User
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?
- AnonymousNot applicable
I feel like this recent thread might hold a similar answer:
http://community.powerbi.com/t5/Desktop/Power-Query-keep-first-and-last-columns-only/td-p/187542
- AnonymousNot 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.
- AnonymousNot 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".