Power Query: Riveting Results Part 7
26 January 2022
Welcome to our Power Query blog. This week, I insert parameters from Excel cells into my query.
My salespeople are in self-isolation. This week, I continue looking at the exam results I created in Power Query: Riveting Results Part 1:
![](http://sumproduct-4634.kxcdn.com/img/containers/main/blog-pictures/2022/power-query/269/image1.png/e774d10cbbb9450fc45efbe51abdf434.jpg)
I will be grading the results, and I will be using this example to explore parameters. Last week, I defined named cells for the other grading bands and created queries for each band:
![](http://sumproduct-4634.kxcdn.com/img/containers/main/blog-pictures/2022/power-query/269/image2.png/f32e5a15e2cf9c3e4d2d058458ce054d.jpg)
I will now apply these parameters to the Exam Results query and check that any changes to the Excel cells affect the outcome of the query.
I return to the Exam Results query.
![](http://sumproduct-4634.kxcdn.com/img/containers/main/blog-pictures/2022/power-query/269/image3.png/f1140ff857fc3b6f5f97a6a24f4a6fc7.jpg)
The easiest way to change the query to use the Excel controlled parameters is by editing in the Advanced Editor, which I can access from the Home tab:
![](http://sumproduct-4634.kxcdn.com/img/containers/main/blog-pictures/2022/power-query/269/image4.png/72aa864d2854c6fefb1083fba0ab5792.jpg)
The ‘Assigned Grade’ step is changed from:
#"Assigned Grade" =
Table.AddColumn(#"Changed Type", "Grade", each
if [Result] > P_Grade_9 then 9
else if [Result] > P_Grade_8 then 8
else if [Result] > P_Grade_7 then 7
else if [Result] > P_Grade_6 then 6
else if [Result] > P_Grade_5 then 5
else if [Result] > P_Grade_4 then 4
else if [Result] > P_Grade_3 then 3
else "Ungraded")
to
#"Assigned Grade" =
Table.AddColumn(#"Changed Type", "Grade", each
if [Result] > DP_Grade_9 then 9
else if [Result] > DP_Grade_8 then 8
else if [Result] > DP_Grade_7 then 7
else if [Result] > DP_Grade_6 then 6
else if [Result] > DP_Grade_5 then 5
else if [Result] > DP_Grade_4 then 4
else if [Result] > DP_Grade_3 then 3
else "Ungraded")
This works because each ‘DP_’ query represents one value:
![](http://sumproduct-4634.kxcdn.com/img/containers/main/blog-pictures/2022/power-query/269/image5.png/36776d1da4d05b45bb5a5d09375f407c.jpg)
This currently has no effect on the results of the query, since the values are the same:
![](http://sumproduct-4634.kxcdn.com/img/containers/main/blog-pictures/2022/power-query/269/image6.png/23912d3b1671861e02bebcd5183f1607.jpg)
However, it does have an effect on the screen accessed by clicking on the cog (gear icon) next to the ‘Assigned Grade’ step:
![](http://sumproduct-4634.kxcdn.com/img/containers/main/blog-pictures/2022/power-query/269/image7.png/6f49c288a0d88a66b427eaf4ece923d6.jpg)
Note that I cannot view the Value column now. Any changes must be made directly to the M code, either from the Advanced Editor or the Formula Bar:
![](http://sumproduct-4634.kxcdn.com/img/containers/main/blog-pictures/2022/power-query/269/image8.png/b9ee28d90e6b5bc92ea4aeafdad51628.jpg)
Back in Excel, if I change the Named cell Grade_3 from 30 to 20 percent, the outcome will change when I refresh the Exam Results query:
![](http://sumproduct-4634.kxcdn.com/img/containers/main/blog-pictures/2022/power-query/269/image9.png/0485ccbc83bdeec1d741bad442a1ea5f.jpg)
If I go back to Exam Results and view all the data, I can see that everyone has passed now!
![](http://sumproduct-4634.kxcdn.com/img/containers/main/blog-pictures/2022/power-query/269/image10.png/daf8c4f0259ce428269c0d3d4badd32b.jpg)
Come back next time for more ways to use Power Query!