cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Krcmajster
Helper IV
Helper IV

Use column values as headers (pivot when there is no unique values)

The title might not the be the best representation. 
I want to load all the flies in the specific folder from Sharepoint. Problem is that users can change column names from time to time, and although data in columns will have same business definintion, column names will be different. E.g. Cost Center can be named as CC, Cost Center, Cost Center #. 

My thought was to unpivot columns and merge the attributes with helper mapping table where I can add all definintions. 
E.g. 
Unpivoted table:

AttributeValue
CC5161
Cost Center46849
Cost Center #619681



After Merge:

AttributeValueMapping
CC5161Cost Center
Cost Center46849Cost Center
Cost Center #619681Cost Center

 

I can't pivot as Mapping will not have unique values. 

end ountcome should be:

Cost Center
5161
46849
619681

 

If there is another solution, I am free to listen

1 ACCEPTED SOLUTION
v-jingzhang
Community Support
Community Support

Hi @Krcmajster 

 

You can refer to this blog: Rename column names in a dynamic way with #Excel #PowerQuery | wmfexcel. It should be helpful. The idea is that you need to have a name mapping table in advance. Since you query data from files in a sharepoint folder, you can perform the column renaming operation on the sample query right after Source step in it. Then it should be applied to the combined query. 

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

View solution in original post

2 REPLIES 2
v-jingzhang
Community Support
Community Support

Hi @Krcmajster 

 

You can refer to this blog: Rename column names in a dynamic way with #Excel #PowerQuery | wmfexcel. It should be helpful. The idea is that you need to have a name mapping table in advance. Since you query data from files in a sharepoint folder, you can perform the column renaming operation on the sample query right after Source step in it. Then it should be applied to the combined query. 

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

edhans
Super User
Super User

If the columns are in the same order, just rename them as they come in. This article will show you how. If they are not in the same order, I am not sure how you would account for column names changing and locations changing.



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

Helpful resources

Announcements
June 2022 update 768X460.jpg

Check it out!

Click here to read more about the June 2022 updates!

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Power BI Dev Camp Session 23 768x460.jpg

Check it Out!

Mark your calendars and join us on Thursday, June 30 at 11a PDT for a great session with Ted Pattison!

June 20 episode 7 with aka link 768x460.jpg

The Power BI Community Show

Join us on June 20 at 11 am PDT when Kim Manis shares the latest on Azure Synapse analytics, the Microsoft Intelligent Data Platform, and notable Power BI Updates from Microsoft Build 2022.

Top Solution Authors