Extracting Data From Multiple Files with Power Query

In this post I’d like to demonstrate another way Power Query can solve simple data extraction problems without much time or effort.  If you’re still learning the basics of Power Query please refer back to an earlier post here.

This demonstration will show you how to use Power Query to scan a file folder to search for a set of files to load.  Then load the contents of multiple files all at once and use transformations to format the data appropriately..

Step by Step

  1. Launch Excel 2010 or higher.
  2. Select the Power Query tab.
  3. Select From File under the Get External Data section of the tab.
  4. Choose the option From Folder, which allows you to load more than one file at once.

image

  1. Browse to a folder, which has the files you desire to load then click OK. These files should all be formatted similarly to each other.  Having the same data types and column names.

image

  1. This opens the Query Editor, which lists all the files that are available in the folder you selected in the previous step.  The initial view show metadata about the files like the file name, extension, relevant dates and the folder path.  If there were other files in this folder that should not be loaded you could filter them out at this point.  The other interesting columns are Content and Attributes.  The Attributes column  has additional metadata that can be queried and the Content column stores the actual data of each file.  Click the down arrows next to the column header for Content. 

image

  1. The data from all four files in now combined together into a single query, but there is still transformations in the data that must be completed.  Start by right-clicking on Column1 header and select Split Column > By Delimiter.

image

  1. Click OK to accept the defaults of configuration, which will split each column by a comma.
  2. Next, right-click on either column header and select Use First Row As Headers to give the query appropriate column names.

image

  1. You will notice the previous step only gave us column headers from the first file.  If you look in the results you will find the column headers listed for the other files too.  To remove these extra column header rows select the down arrow next to the Name column and uncheck the Name value then click OK.

image

  1. You have now successfully combined 3 files using Power Query.  Click Done to bring this data into Excel.  Once in Excel this can easily be added to tools like Power Pivot for additional analysis.

Hope this helps!

About these ads

2 Responses

  1. […] Extracting Data From Multiple Files with Power Query […]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 36 other followers

%d bloggers like this: