cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
clemensbauer Frequent Visitor
Frequent Visitor

Rename column headers in power query advanced editor

I' ve two tables in my editor. One contains data and the other contains translations for the column header.

 

#"Table1"

|active|activationName|descriptiveText|

| 1      |  Sample            | Is a sample.    |

| 2      | Exampl2           | This another   |

 

#"Table2"

| dbColumnName | label|

| descriptiveText| Description|

|activationName| Name of Activation|

|active                | Activated|

 

Now I want to translate the column header of the first column with the names of the second table using power query advanced editor. I found an example the forum to remove "_" in the header table name :

 

#"Result" = Table.RenameColumns(#"Table1", Table.ToRows(Table.AddColumn(Table.FromList(Table.ColumnNames(#"Table1")), "New Column Name", each Text.Replace ( [Column1] , {"Column1.dbColumnName"} , {"Column1.label"} ))))

Therefore, I tried to edit the request in the way that column dbColumnName shall be found and replaced with Column1.label.

 

But that doesn't work out. How can I do this?

 

1 ACCEPTED SOLUTION

Accepted Solutions
MarcelBeug Super Contributor
Super Contributor

Re: Rename column headers in power query advanced editor

If you mean that you want to translate the column header of the first table with the labels of the second table:

 

 #"Renamed Columns" = Table.RenameColumns(Table1,Table.ToRows(Table2), MissingField.Ignore)

You can omit the , MissingField.Ignore, but then you will get errors if any of the dbColumnNames in Table2 doesn't exist in Table1.

 

Specializing in Power Query Formula Language (M)

View solution in original post

1 REPLY 1
MarcelBeug Super Contributor
Super Contributor

Re: Rename column headers in power query advanced editor

If you mean that you want to translate the column header of the first table with the labels of the second table:

 

 #"Renamed Columns" = Table.RenameColumns(Table1,Table.ToRows(Table2), MissingField.Ignore)

You can omit the , MissingField.Ignore, but then you will get errors if any of the dbColumnNames in Table2 doesn't exist in Table1.

 

Specializing in Power Query Formula Language (M)

View solution in original post

Helpful resources

Announcements
New Ranks and Rank Icons in 2020

New Ranks and Rank Icons in 2020

Read the announcement for more information!

New Kudos Given Badges Coming

New Kudos Given Badges Coming

We're rolling out new Kudos Given badges. Find out how many Kudos you've given.

November 2019 Community Highlights

November 2019 Community Highlights

Get an overview of the events and great community content from November.

Power Platform World Tour

Power Platform World Tour

Find out where you can attend!

Top Solution Authors
Top Kudoed Authors (Last 30 Days)