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
andy_vdg
Regular Visitor

Rename columns based on data in another table

Hi 

This is similar to https://community.powerbi.com/t5/Desktop/Auto-renaming-columns-based-on-value-in-another-table/m-p/7... with some added complexity

 

I have a rather large table (from JIRA) with quite a few columns that are named in the following format

customfield_XXXXX - note that not all columns have this name. 

image.png

I have another table which defines the custom field name.

image.png

For all columns that are named customfield_XXXXXX I want to look up the cfname value in the other table and replace the column header in Table1. 

 

The above answer I found only works if all column headers are to be replaced - my scenario requires finding each column to be replaced, stripping the ID from the current name and then replacing it with the value from the other table. 

 

Any help would be greatly appreciated. 

Andy

1 ACCEPTED SOLUTION
v-chuncz-msft
Community Support
Community Support

@andy_vdg,

 

Based on my test, you may refer to the following code.

    #"Renamed Columns" = Table.RenameColumns(Source
                                            , Table.ToRows(Table.SelectColumns(Table.AddColumn(Table2, "ID2", each "customfield_" & Text.From([ID]))
                                                                                , {"ID2", "cfname"}))
                                            , MissingField.Ignore)
Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-chuncz-msft
Community Support
Community Support

@andy_vdg,

 

Based on my test, you may refer to the following code.

    #"Renamed Columns" = Table.RenameColumns(Source
                                            , Table.ToRows(Table.SelectColumns(Table.AddColumn(Table2, "ID2", each "customfield_" & Text.From([ID]))
                                                                                , {"ID2", "cfname"}))
                                            , MissingField.Ignore)
Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@andy_vdg @v-chuncz-msft 

I am doing a jira analysis and my question is a bit similar to this issue.
https://community.powerbi.com/t5/Desktop/Rename-the-columns-of-a-table-using-the-values-from-another...
Can you please help me with this issue?

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.