Power Query: Excel Files from a Folder Fiddle – Part 1
8 November 2023
Welcome to our Power Query blog. Today, I look at an issue I encountered recently when importing Excel files from a folder.
In Power Query: Returning to the Folder, I looked at how the process to import files from a folder had been made easier by using the ‘Combine Files’ functionality:
![](http://sumproduct-4634.kxcdn.com/img/containers/main/./image1-1699038370.png/607f8a35b3fb4819bb22932e5d62c20f.jpg)
This worked successfully for a folder of CSV (comma delimited) files.
![](http://sumproduct-4634.kxcdn.com/img/containers/main/./image2-1699038393.png/d1a0761f8b8c4d623be4c6103179a0e9.jpg)
The files and functions in the ‘Helper Queries’ folder worked, and my data was successfully combined. However, when I have some Excel files in a folder, the process does not go so smoothly. In a new blank workbook, I choose to extract a folder of Excel files:
![](http://sumproduct-4634.kxcdn.com/img/containers/main/./image3-1699038419.png/6ade6260039a6a71d0fe3afd4085d6e3.jpg)
I browse to the folder location, and choose to ‘Open’ the folder:
![](http://sumproduct-4634.kxcdn.com/img/containers/main/./image4-1699038436.png/ef603e1d6bcd71cfcb05cb0e9d12ec1a.jpg)
I choose to ‘Transform Data’:
![](http://sumproduct-4634.kxcdn.com/img/containers/main/./image5-1699038464.png/7cc002cad13407685f53242ac44601c4.jpg)
Note that if this were a real-life scenario, I would add a lowercase and filter transformation to the Extension column, to ensure only the required file types were loaded, but here I am concentrating on the issue and how to solve it. I only need the Content column, so I select it and choose ‘Remove Other Columns’ from the right-click menu:
![](http://sumproduct-4634.kxcdn.com/img/containers/main/./image6-1699038498.png/674ca3668b13ea676401401b33fc274c.jpg)
I can then use the icon next to the Content heading to combine the Binary files.
![](http://sumproduct-4634.kxcdn.com/img/containers/main/./image7-1699038529.png/f4663741ce47c683ee94e783e3fad0f9.jpg)
I am then prompted to check my data, and everything looks fine, so I click ‘OK’:
![](http://sumproduct-4634.kxcdn.com/img/containers/main/./image8-1699038546.png/bbb835d66e34261f7fa1c0eee65d18f8.jpg)
Power Query generates the ‘Helper Queries’ folder and creates some steps for me, but there is a problem:
![](http://sumproduct-4634.kxcdn.com/img/containers/main/./image9-1699038580.png/d02a4bd750957fdaf71003d1657045ae.jpg)
I have a red wavy line under my headings, and a row of errors instead of the rest of the data in the folder. I only have one sheet of data from the first Excel file. If I click on the error, the message is not helpful:
![](http://sumproduct-4634.kxcdn.com/img/containers/main/./image10-1699038606.png/84815af63a585d1fc04d0e43bca224c2.jpg)
The error message mentions “the ‘Transform File’ Query”. This function has been generated by Power Query and uses the steps in Transform Sample File.
![](http://sumproduct-4634.kxcdn.com/img/containers/main/./image11-1699038627.png/86122968859eb6f8419b5577bf88e5d4.jpg)
This appears to be a very simple query, so this doesn’t help me. If I look at the steps that Power Query has generated, the first step with an error is ‘Invoke Custom Function1’:
![](http://sumproduct-4634.kxcdn.com/img/containers/main/./image12-1699038650.png/2aeca9cd6fa4adf90408fa07605edb65.jpg)
This has failed to extract the second and third tables. Since the Power Query combine method has failed, I need to find another way to append my data together. Next time, I will create the steps I need to solve this issue.
Come back next time for more ways to use Power Query!