Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

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

1 ACCEPTED SOLUTION
Anonymous
Not applicable

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"}})

 

View solution in original post

6 REPLIES 6
GilbertQ
Super User
Super 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?





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!







Power BI Blog

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".

 

 

Anonymous
Not applicable

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
Not applicable

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"}})

 

Anonymous
Not applicable

@Anonymous,

 

Thanks for that. Works great!

 

Almost had it but didn't quite have the syntax with the braces right so sincerely appreciate the assist,

 

Cheers,

Andrew.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.