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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

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