# Power Query - Dynamic Column Headers - By Date



## lager1001 (Oct 11, 2019)

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.


----------



## sandy666 (Oct 11, 2019)

try with additional table with headers before and headers after, then append, promote , etc...


----------



## lager1001 (Oct 14, 2019)

Hi sandy666,

Can you explain?


----------



## sandy666 (Oct 14, 2019)

Post representative example of source data and expected result


----------



## lager1001 (Oct 14, 2019)

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.


----------



## sandy666 (Oct 14, 2019)

I am glad you solved your problem

Have a nice day


----------

