Forum Discussion
Add Excel Data Source with Additional Columns
- 5 years ago
You can see the M code in the Advanced Editor in Power Query (right click on any query, click "Advanced Editor". If you used the official merge option there will be a new section with a ingestion function and a sample file reference. Walk through the generated code, and find the place where it mentions the sample file (for the headers). Usually it is the first file in your list.
That may actually give you an in. When you list the items in the sharepoint folder, sort them in a way that newer files come first. Then the merge code will pick up the new structure (and gracefully merge the older files even if they are missing the new column).
Hello jsuttmann
the bottleneck here is the ExpandTableColumn-function that hardcoded the column from your first file (sample file). To overcome this you have to write this part of your code dynamically. So instead of gettting the columnnames of the first file
(the code that look like this Table.ColumnNames(TransformFile(SampleFile)) )
you have to change it to something dynamically like this
Table.ColumnNames(Table.Combine(PreviousStep[ColumnNameOfExtractedFiles]))
without seeing your code I cannot give you the exact to code to put
If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
Kudoes are nice too
Have fun
Jimmy