Forum Discussion
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:
| Attribute | Value |
| CC | 5161 |
| Cost Center | 46849 |
| Cost Center # | 619681 |
After Merge:
| Attribute | Value | Mapping |
| CC | 5161 | Cost Center |
| Cost Center | 46849 | Cost Center |
| Cost Center # | 619681 | Cost 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
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.
2 Replies
- edhansCommunity Champion
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.
- v-jingzhangCommunity 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.