Power Query: PDF Pandemonium – Part 4
6 October 2021
Welcome to our Power Query blog. This week, I continue transforming some data that is coming in from a PDF file, by creating transformations in preparation for developing a function next week.
The tent business is continuing to do well, and the UK division still plans to expand the workforce. I have a PDF file, and it contains tables for 10 stores. Last week, I transformed Pay Scales and this week I turn to the Stores table.
![](http://sumproduct-4634.kxcdn.com/img/containers/main/blog-pictures/2021/power-query/253/image1.png/e774d10cbbb9450fc45efbe51abdf434.jpg)
I have 10 stores in my table, and I need to perform the same transformations for each one. The first step I will take is to merge the columns I need for Store 1. I select Store 1, Pay Scales and Workforce expansion whilst holding down the CTRL key. When I right-click, I have the option to ‘Merge Columns’.
![](http://sumproduct-4634.kxcdn.com/img/containers/main/blog-pictures/2021/power-query/253/image2.png/f32e5a15e2cf9c3e4d2d058458ce054d.jpg)
Clicking on this option reveals a dialog:
![](http://sumproduct-4634.kxcdn.com/img/containers/main/blog-pictures/2021/power-query/253/image3.png/f1140ff857fc3b6f5f97a6a24f4a6fc7.jpg)
I choose not to use a separator, since I can split by non-numeric and numeric characters later. I want to call my new column Store 1, but Power Query won’t let me do this as this is one of the names of the original columns, so for now I take the default Merged.
![](http://sumproduct-4634.kxcdn.com/img/containers/main/blog-pictures/2021/power-query/253/image4.png/72aa864d2854c6fefb1083fba0ab5792.jpg)
I can adjust the step created from:
Table.CombineColumns(Table.TransformColumnTypes(Source, {{"Store 1", type text}}, "en-AU"),{"Store 1", "Pay Scales", "Workforce#(lf)expansion"},Combiner.CombineTextByDelimiter("", QuoteStyle.None),"Merged")
to:
Table.CombineColumns(Table.TransformColumnTypes(Source, {{"Store 1", type text}}, "en-AU"),{"Store 1", "Pay Scales", "Workforce#(lf)expansion"},Combiner.CombineTextByDelimiter("", QuoteStyle.None),"Store 1")
This is then accepted with no issues:
![](http://sumproduct-4634.kxcdn.com/img/containers/main/blog-pictures/2021/power-query/253/image5.png/36776d1da4d05b45bb5a5d09375f407c.jpg)
I repeat this for the other stores.
![](http://sumproduct-4634.kxcdn.com/img/containers/main/blog-pictures/2021/power-query/253/image6.png/23912d3b1671861e02bebcd5183f1607.jpg)
I could keep working on all the stores together, but it would soon become a large table. Instead, I am going to work on the stores separately. Before I do this, I need to make sure that the store name is included in the data, so I demote headers using the option from the Transform tab:
![](http://sumproduct-4634.kxcdn.com/img/containers/main/blog-pictures/2021/power-query/253/image7.png/6f49c288a0d88a66b427eaf4ece923d6.jpg)
My data is now safely stored in the rows, and I can create a query from a column. I right-click with Column1 selected:
![](http://sumproduct-4634.kxcdn.com/img/containers/main/blog-pictures/2021/power-query/253/image8.png/b9ee28d90e6b5bc92ea4aeafdad51628.jpg)
This creates a new List Query.
![](http://sumproduct-4634.kxcdn.com/img/containers/main/blog-pictures/2021/power-query/253/image9.png/0485ccbc83bdeec1d741bad442a1ea5f.jpg)
I will rename my List Query to Store 1 to reflect the data.
![](http://sumproduct-4634.kxcdn.com/img/containers/main/blog-pictures/2021/power-query/253/image10.png/daf8c4f0259ce428269c0d3d4badd32b.jpg)
What I want now, is to create a series of steps that will work on any of the stores. I need a function. I start by taking a reference copy of Store 1.
![](http://sumproduct-4634.kxcdn.com/img/containers/main/blog-pictures/2021/power-query/253/image11.png/22c6daeb82d7d69ac88f878227e04b28.jpg)
I call my new query fn_store.
![](http://sumproduct-4634.kxcdn.com/img/containers/main/blog-pictures/2021/power-query/253/image12.png/a1537847463e660a31158c8032525438.jpg)
The first step is to convert this list to a table. I can do this from the List tab or I may otherwise right-click.
![](http://sumproduct-4634.kxcdn.com/img/containers/main/blog-pictures/2021/power-query/253/image13.png/917da985be13220165c8d2823e95344f.jpg)
A dialog appears where I shall accept the defaults:
![](http://sumproduct-4634.kxcdn.com/img/containers/main/blog-pictures/2021/power-query/253/image14.png/8c3be7af9f73d031acae69ed85a2e148.jpg)
This gives me access to the other tabs.
![](http://sumproduct-4634.kxcdn.com/img/containers/main/blog-pictures/2021/power-query/253/image15.png/e63c0a4c21afc9afb438aacc09a59317.jpg)
I start by promoting the first row to headers using the option on the Transform Tab.
![](http://sumproduct-4634.kxcdn.com/img/containers/main/blog-pictures/2021/power-query/253/image16.png/d082e3477129350b8a2a589156028e63.jpg)
I am ready to enter the transformations required and convert this query into a function next time.
Come back next time for more ways to use Power Query!