How to run multiple Merge Queries in Power Query [x-post SO]

Joined
Jan 30, 2022
Messages
30
Office Version
  1. 365
Platform
  1. Windows
Crossposted to Stack Overflow:

I have six sheets in my workbook containing a combined 140 columns, five of which I have set up as connection-only queries, and one which is the actual merge query. All sheets have values in Person ID and start date which are used to merge the worksheets (left join). With the exception of the first sheet (adding an index column for duplicates and a filter column to remove specific types of rows), the merge process is identical. The number of columns does change in each sheet but they are all matched by Person ID and Start Date and are all declared as table ranges.

I am trying to automate this but the Power Query code is 18,500 Characters long without line breaks. Steps are very basic: add index, merge, expand, merge, expand, merge, expand, filter index to remove duplicates, load.

I have been trying to fit the code into my macro for hours with no luck - it keeps throwing "too complex" with line breaks. I am trying to declare each line as a variable and the stringing them together but I'm getting a lot of errors.

Can't add demo code as this contains a lot of variables specific to my job.

All sheets need to be joined as the total columns represents one batch report - these need to be merged sequentially to the first sheet, which contains specific client detail and quotes. It is a horrible system, I know, but fixing it is beyond the scope of my role!

All suggestions appreciated.
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.

Forum statistics

Threads
1,223,754
Messages
6,174,314
Members
452,554
Latest member
Louis1225

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