Please note javascript is required for full website functionality.

Blog

Power Query: Riveting Results Part 8

2 February 2022

Welcome to our Power Query blog. This week, I create a parameter to define the location of another Excel source file.

My salespeople are working from home. This week, I continue looking at the exam results I created in Power Query: Riveting Results Part 1:

I will be grading the results, and I will be using this example to explore parameters. Last week, I amended my query to use parameters from Excel cells in the same workbook.

However, I now want to store the grading bands in a separate workbook away from the exam results.

The new bands are stored in a workbook which I have called ‘Blog 270 Exam Grade Bands’.

Back in my original workbook, I need to extract the data. I can do this by creating a new query from the ‘Get Data’ dropdown in the ‘Get & Transform’ section of the Data tab. Note that to extract data ‘From Workbook’, the Excel file I am extracting from must not be open.

In the dialog, I find the workbook I wish to use:

I can then choose to ‘Import’.

In the Navigator dialog, I can see the Named Cells and the ‘Parameters’ Sheet. I select Grade_9:

I plan use to this as my base query. I opt to ‘Transform Data’:

I am interested in the Source step:

The Source step points at the Excel file I have created. To reduce future maintenance, and to add flexibility I am going to create a base query which only includes the Source step, and then I am going to use a parameter to point to the file location. If I have a base query, then any changes I make to the Source step only need to be made once. I delete the other steps and call the query ‘Base Query’:

I create a new Parameter from the ‘Manage Parameters’ option on the Home tab:

I call the new Parameter FilePath:

I define the type as ‘Text’ and enter the ‘Current Value’ as the location of the external workbook that contains the grading bands.

Next time, I will use FilePath in Base Query.

Come back next time for more ways to use Power Query!

Newsletter