Power Query: Heading Off – Part 4
6 March 2024
Welcome to our Power Query blog. Today, I continue to consider an issue that occurs when I load to a Table with no headers.
I plan to show a particular issue with Power Query and Tables without headers. However, first I need to create the scenario, and I will show a few methods and tips along the way. I have two Tables of data:
- contains my salespeople’s expenses (Expenses)
- determines the expenses that will be covered by each supplier (Supplier_Limit).
![](http://sumproduct-4634.kxcdn.com/img/containers/main/./image1-1707825650.png/aa6a630d974a08485e96cc9cac44d60c.jpg)
In Part 1, I created two [2] queries, and grouped Expenses.
![](http://sumproduct-4634.kxcdn.com/img/containers/main/./image2-1707825686.png/7e53ea951ecdfdb376f80cd79b881770.jpg)
In Part 2, I merged Expenses with the Supplier_Limit query to create Limit_Exceeded, which tells me if any limits have been breached.
![](http://sumproduct-4634.kxcdn.com/img/containers/main/./image3-1707825705.png/e7da87c7411b4e5fb9b0746fe6e6b431.jpg)
Last time, I loaded Limit_Exceeded to a new worksheet.
![](http://sumproduct-4634.kxcdn.com/img/containers/main/./image4-1707825875.png/b4c1ddcfad5b9a0f473d130f0140c36b.jpg)
I removed the header row and changed some of the data in Expenses.
![](http://sumproduct-4634.kxcdn.com/img/containers/main/./image5-1707845435.png/d25a2b6d46133fabaa875143a28bf68b.jpg)
This time, I will see what happens when the requirements change, and I run the query for a single salesperson. On the ‘Expenses’ sheet, cell N2 contains the salesperson value I want to use. This cell may be identified by the name P_Salesperson:
![](http://sumproduct-4634.kxcdn.com/img/containers/main/./image6-1707845452.png/bc439916c1021ea432ed3b8654565991.jpg)
If I right-click on cell N2, I have the option to ‘Get Data from Table/Range’.
![](http://sumproduct-4634.kxcdn.com/img/containers/main/./image7-1707845471.png/690bea37f476f0f052802ed2a1e848fb.jpg)
This creates a new query called P_Salesperson:
![](http://sumproduct-4634.kxcdn.com/img/containers/main/./image8-1707845487.png/e9a3990ea4a8b1a659693ff4a263b8ce.jpg)
Note that Power Query has decided to promote headers, leaving an empty table! The ‘Changed Type’ step is also ineffective since there is no data to work with. I only need the Source step, so I delete the other steps:
![](http://sumproduct-4634.kxcdn.com/img/containers/main/./image9-1707845507.png/647c4e8490739e467d29925f0cb05f6b.jpg)
I click in the cell and right-click to ‘Drill down’:
![](http://sumproduct-4634.kxcdn.com/img/containers/main/./image10-1707845523.png/092a982fe8383cf05bd78d9dbb29bd2a.jpg)
This gives me the parameter I need.
![](http://sumproduct-4634.kxcdn.com/img/containers/main/./image11-1707845542.png/773bf8a9f0d90bca9a5a8c684e8d4870.jpg)
Since I will be reducing the data, I should apply the parameter as close to the source as possible (ignoring the option of doing this in Excel as this is a Power Query blog!). In the Expenses query, I go to the Source step:
![](http://sumproduct-4634.kxcdn.com/img/containers/main/./image12-1707845563.png/5738a5c6107cc2efa6fbe334d82cc566.jpg)
I may add a filter on Salesperson:
![](http://sumproduct-4634.kxcdn.com/img/containers/main/./image13-1707845578.png/33bb452d6049e35b597a431cddfec020.jpg)
I choose ‘Mary’ as my placeholder value. I will change this to P_Salesperson later. When I click OK, I received a warning:
![](http://sumproduct-4634.kxcdn.com/img/containers/main/./image14-1707845600.png/3e6b8bf436e644cdd0d0fd7f4d6ce953.jpg)
I may ignore the warning and click Insert, as I am happy to insert a step.
![](http://sumproduct-4634.kxcdn.com/img/containers/main/./image15-1707845614.png/2f8659dd3b34edc66868824fb228ec08.jpg)
The M code for the ‘Filtered Rows’ step is:
= Table.SelectRows(Source, each ([Salesperson] = "Mary"))
To use the parameter, I change this to:
= Table.SelectRows(Source, each ([Salesperson] = P_Salesperson))
This gives me the same results:
![](http://sumproduct-4634.kxcdn.com/img/containers/main/./image16-1707845676.png/d1d7969ca2f70c7e93f2955508252513.jpg)
My final query now looks like this:
![](http://sumproduct-4634.kxcdn.com/img/containers/main/./image17-1707845692.png/25d746be43905c284f47a0bb8ed861b2.jpg)
Now I have reduced the data in Expenses, I check the Limit_Exceeded query.
![](http://sumproduct-4634.kxcdn.com/img/containers/main/./image18-1707845716.png/fa3f925328b29614cd6a2653cafb8e22.jpg)
I now only have one [1] row. I ‘Close & Load To…’ as I did last week, so that my parameter query can be set to ‘Connection Only’:
![](http://sumproduct-4634.kxcdn.com/img/containers/main/./image19-1707845760.png/38f2fb32e636a27683de2f70f3d32b19.jpg)
I refresh Limit_Exceeded and look at the results:
![](http://sumproduct-4634.kxcdn.com/img/containers/main/./image20-1707845781.png/acbf342842f3dc5cd06f32eb7b6c86fc.jpg)
The results correctly show one row of data and no headings. However, things change when I select a different Salesperson:
![](http://sumproduct-4634.kxcdn.com/img/containers/main/./image21-1707845800.png/cc302ebcb9d903e61e11683f06be312f.jpg)
More on this next time!
Come back next time for more ways to use Power Query!