It's time for Power Query Challenge 4! This one is a tricky little challenge with creating a header row - but from different rows in the data set.
The real world scenario driving Power Query Challenge 4
Have you ever tried to combine Excel files in a folder, and wanted to preserve the worksheet name along with the contents? If you have, you'll end up looking at data that follows this kind of pattern:
Notice that in step 1 we have the sheet name and a table with the contents. And step 2 shows what happens when we expand all columns from the table. So what's the issue?
This is the crux of Power Query Challenge 4… we need a header row that looks like this:
Easy right? Not so fast!
The value in the Name column will change for each file in the folder. In addition, the data in the columns may also have different names. So you can't hard code anything here…
Sample data for Power Query Challenge 4
Let's be honest, this isn't simple or it wouldn't be a challenge, but we're going to try and keep it simpler by focussing on just the header row issue. (We're going to skip the whole combine files stuff, and just use some pre-formatted Excel tables that exhibit the problem.)
To build and test your solution I'm providing a file with two different data tables (Admin and Sales) and a query called "MakeMyHeaders" that just refers to the Admin data set right now:
The data in the Admin table looks like this:
And Sales looks like this:
Solving Power Query Challenge 4
To solve this challenge, you should work in the MakeMyHeaders query, and convert the data so that it outputs the data shown here:
And, if you did it correctly, you should then be able to edit the MakeMyHeaders query, select the Source step and change the formula to =Sales. After loading, you should get the output shown here (without any errors):
Posting Your Solution
As mentioned in The Future of Power Query Challenges, we are no longer accepting submissions by email. And don't post your solution here either. (Comments are still welcome!) Instead, we are collecting answers on the Power Query Challenge 4 thread in our forum. Post your solution there, provide a short description of the approach you took, and have a look at other's submission there.
My solution will come out as a blog post tomorrow.