Power Query - Dynamic Column Headers - By Date

lager1001

Board Regular
Joined
May 17, 2019
Messages
88
I import a file each day that contains about 40 columns of data. 15 of the 40 column headers are dates for the next 15 days from the current date. Therefore, each day the column headers change in the source data for those 15 columns. My refresh will crash each day since it cannot find the exact same column names from the previous day. I found the following youtube video which explains how you can rename the columns dynamically but it doesn't appear to be working for me (I get a token comma expected error and have followed the coding exactly). Additionally, the video only shows the coding for dynamically updating 1 column header. Does anyone know how to dynamically update multiple column headers each time a fresh is done to prevent crashing?

https://www.youtube.com/watch?v=yBJr0sAc-m4

Thank you.
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
try with additional table with headers before and headers after, then append, promote , etc...
 
Upvote 0
Post representative example of source data and expected result
 
Last edited:
Upvote 0
I was able to figure this out. I made a separate worksheet for the headers only but it was just a range, not a table, since you can't have formulas in table headers. I then made the column names all the same except for the dated ones which i used formulas for to pull the proper new names for. I then pulled a Power Query out of this worksheet, promoted first row to headers and appended the source data file with the changing dated headers. Works great.
 
Upvote 0

Forum statistics

Threads
1,223,888
Messages
6,175,213
Members
452,618
Latest member
Tam84

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top