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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Hrb-9
New Member

Rename columns from list

New to power query, so hoping for some help whilst I learn. Thanks in advance

 

I have a master table with column names which are codes e.g. XCGY, CHTY, HGFT, etc

 

i have a secondary table where column 1 is the list of codes and column 2 contains the useful column name I would like to use. 

Can I use power query to quickly rename all columns in table 1 based on the info from table 2?

1 ACCEPTED SOLUTION
ronrsnfld
Super User
Super User

Assume your translation table is named Translate with the columns Code and Friendly

 

Table.RenameColumns(#"Step to Rename",List.Zip({Translate[Code], Translate[Friendly]}), MissingField.Ignore)

 

Translate Table

ronrsnfld_0-1710984638535.png

 

Table with code names

ronrsnfld_1-1710984675345.png

Sample Code

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("RYzBDoAgDEP/ZWf+CDigloxEIRnj4N87lxgv3fraNEZSbpPCdxiClOwp/aAcIjn9pbZezvP2SBlGJvZh3UB9XRvEp+B5bTLVvCPBW65jiTLl/AA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [abc = _t, ghi = _t, def = _t, jkl = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"abc", type text}, {"ghi", type text}, {"def", type text}, {"jkl", type text}}),
    
    #"Rename Columns" = Table.RenameColumns(#"Changed Type",List.Zip({Translate[Code], Translate[Friendly]}), MissingField.Ignore)
in
    #"Rename Columns"

 

with Columns Renamed

ronrsnfld_2-1710984749331.png

 

 

 

View solution in original post

1 REPLY 1
ronrsnfld
Super User
Super User

Assume your translation table is named Translate with the columns Code and Friendly

 

Table.RenameColumns(#"Step to Rename",List.Zip({Translate[Code], Translate[Friendly]}), MissingField.Ignore)

 

Translate Table

ronrsnfld_0-1710984638535.png

 

Table with code names

ronrsnfld_1-1710984675345.png

Sample Code

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("RYzBDoAgDEP/ZWf+CDigloxEIRnj4N87lxgv3fraNEZSbpPCdxiClOwp/aAcIjn9pbZezvP2SBlGJvZh3UB9XRvEp+B5bTLVvCPBW65jiTLl/AA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [abc = _t, ghi = _t, def = _t, jkl = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"abc", type text}, {"ghi", type text}, {"def", type text}, {"jkl", type text}}),
    
    #"Rename Columns" = Table.RenameColumns(#"Changed Type",List.Zip({Translate[Code], Translate[Friendly]}), MissingField.Ignore)
in
    #"Rename Columns"

 

with Columns Renamed

ronrsnfld_2-1710984749331.png

 

 

 

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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