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
clemensbauer
Regular 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
MarcelBeug
Community Champion
Community 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.

 

Specializing in Power Query Formula Language (M)

View solution in original post

1 REPLY 1
MarcelBeug
Community Champion
Community 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.

 

Specializing in Power Query Formula Language (M)

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.