Forum Discussion

clemensbauer's avatar
clemensbauer
Regular Visitor
9 years ago
Solved

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?

 

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

     

1 Reply

  • MarcelBeug's avatar
    MarcelBeug
    Icon for Community Champion rankCommunity Champion

    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.