Forum Discussion
How to combine multiple excel data using power query
- Dec 16, 2023
In attached file a query that combines all sheets in all workbooks
If this is what you want to do, update the Folder path with yours in sheet 'PARAM' > Refresh the query in sheet 'Query Result'
however within headers there is some additional spaces at start or end in few excel sheets
Below is a simulation. Not obvious but Sheet2 headers are: ' abc '; 'def '; ' ghi '
What you need to do, after Promoting Headers on each sheet, is to add a step (with the Advanced Editor) to Trim the header names (https://learn.microsoft.com/en-us/powerquery-m/table-transformcolumnnames). Example with above Sheet1:
let
Source = Excel.CurrentWorkbook(){[Name="Sheet1"]}[Content],
PromotedHeaders = Table.PromoteHeaders(Source, [PromoteAllScalars=true]),
TrimmedHeaders = Table.TransformColumnNames(PromotedHeaders, Text.Trim)
in
TrimmedHeadersthen you combine your sheets
Re. Getting error for few excel sheets which have additional spaces
Sorry but this means nothing/doesn't help if you don't post the corresponding error message