Power Query: Riveting Results Part 2
22 December 2021
Welcome to our Power Query blog. This week, I create parameters for last week’s example.
My salespeople are still taking a break. We will keep looking at those exam results from last week:
I will be grading the results, and I will be using this example to explore parameters. Last time, I created a column to grade the results:
I am now ready to create some parameters to calculate the grades. To begin with, I will enter these parameters from the ‘Manage Parameter’ option on the Home tab:
I opt to create a ‘New Parameter’. This brings up a dialog:
I am going to enter a parameter for each grade. I call my first parameter P_Grade_9:
The ‘P_’ is to indicate it is a parameter. This will make it easy to spot in the list of queries. I also enter a description. When I choose the Type, there is no option for percentage, so I make it a ‘Decimal Number’ instead.
For now, I will allow ‘Any value’. I will be revisiting the ‘Suggested Values’ dropdown for this example later.
To complete this parameter, I enter a ‘Current Value’ of 90. If I were to click ‘OK’ at this point, the parameter would be created, and I would automatically exit the dialog:
I can see the parameter in the Queries panel. If the parameter is selected, then I can edit the ‘Current Value’ if I wish. The ‘Current Value’ also appears next to the parameter in brackets ‘(90)’ so that I can always see what it is set to in the Queries panel.
If I want to create multiple parameters, then I can stay in the ‘Manage Parameter’ dialog by clicking ‘New’ instead of ‘OK’ when I have finished each parameter:
Note that since my parameters are similar, I can also copy and paste or create Duplicates:
This is fine, as long as I remember to change the name, description and ‘Current Value’.
Do not create a ‘Reference’. This would return the ‘Current Value’ of the parameter:
The icon next to P_Grade_8 (2) indicates a number. Note also that the ‘(2)’ in this case is created because there is already a P_Grade_8 and is not the value!
I now have all my parameters ready for the next step:
Come back next time for more ways to use Power Query!