List range Power Query
In a previous post we explored how to import all the files in a folder using power query. But what happens when we get a new batch of data files and we need to import them for analysis? In this post we are going to find out how to reference thefolder path using a named range in our workbook. This will allow us toeasily change the path of the folder and import different sets of files into Excel. Show For this youre going to need to be familiar with what we did in the previous post as this post takes off where that one left off. So have a read of this first. How To Import All Files In A Folder With Power Query Step 1: Create a query to get the named range.Firstly create a named range to reference. I have called my named range FilePath and copied in a new folder location.
Now in Query Editor we can add in our M code to create our query function.
Close and load the new query.
Step 2: Edit our data query to use the new function.Edit the data query.
Now we need to edit our query to remove the hard coded folder path location.
In the query preview you will notice the Folder Path field values have updated.
Step 3: Updating the query.Now if you have a new folder with new data files in it, youll be able to easily change the import folder path and refresh the query.
|