Power Query Capabilities
In the last post, I showed you how to bring in data from PDFs into Excel through Power Query. This post will detail some of the rudimentary power query capabilities to get you started.
If you need to know how to access Power Query, just follow along the last post located here.
Otherwise, continue reading to learn about a few of Power Query capabilities.
Power Query editor
At the end of the last post after clicking on the “Transform” button, we ended up on the Power Query editor page, as seen below.
I blew up image 1 so you can see it better because there are a few things to know about the editor.
On the left you can see the various Pages. The one highlighted is the one you are seeing in the middle of image 10.
On the right in the Power Query settings box, you will see a list of steps that have been performed thus far.
Also, there is a menu system along the top of the screen, just like Excel. It is well worth your time to explore the menu system. You won’t understand all of its features yet but as time goes on, you will start to recognize the menu items.
Power Query Capability 1: Remove rows
First, I’m going to remove rows to get at the desired headers (date, value, Party, President, etc) found in row 8. Removing rows is a very common need.
In this instance, I will be removing 7 rows to get at the headers, so that number is entered into the “Number of rows” box.
Capability 2: Making first row as header
I hope this is self-explanatory.
Capability 3: Remove columns
Similar to removing rows, we have the ability to remove columns to what we only need.
Capability 4: Rename your headers
As far as I know, there is no renaming feature in the menu system. I’ve been reaching for it through selecting the header and then right clicking to pull up a table of options.
Capability 5: Splitting columns
Sometimes you need to split columns because information has been merged together during the importing process. In my case, the value and the Party column came in together.
After clicking on the “Split Column” icon, you will be asked to show how you want to split the column.
In column 2 of Page008, the value came in along with the Party. Note that the value is separated from the Party with a space, so I use that as a delimiter under the Customs box. You can’t really see it in image 18, but I keyed in a space in the box beneath the “–Custom–” box.
Capability 6: Merging all of the tables
After I go through each Pages renaming headers and splitting columns, I can now merge those Pages through the “Append Queries” tool. Append allows you to combine tables with the same layout into one table. Merging allows you to add more headers.
One really important thing I learned: the headers must be the same, including the same capitalization. Power Query regards “date” as different from “Date”. I had to go back and clean up one of my Pages to make the headers consistent.
After all of the prep, I am now ready to append those pages.
Images 11 and 12 are showing the steps I am taking to append all of those pages. You can use the shift key to select multiple choices at once and then click on the “Add” button to move everything at once to the box on the right side.
Once you click “Ok” during the append process, you will come back to the editor screen with a new table sitting on the left-hand side. In my case, it is called “Append1” and it contains all of the pages in one table. Please double check to make sure the information came in correctly. This was when I found out that the column headers capitalization/non-capitalization mattered.
Now bring data into Excel
When you are ready to pull everything together into the Excel, click on “Close and load” found in the upper left-hand corner.
Notice that closing led to the formation of a couple of sheets, one for each table. You will see multiple tabs at the bottom and multiple tables on the right side in the “Queries and Connections” box. You can delete those tabs. Watch how the right side changes.
Closing comments
There is so much more to Power Query capabilities; I have shown you only a very, very small portion of what Power Query offers. What I have shown are the ones I most typically use to get started, but you can do some very powerful things.
You must be logged in to post a comment.