How can I add parameters to run a query from power query in excel?

krodriguez

Board Regular
Joined
Jul 11, 2012
Messages
119
Hello,

I have a query using power query in excel (see below), and looking to speed up the process of updating the results using parameters for two dates (only this will change) this parameters will be on separate worksheet and by changing the dates query should update automatically.

reportdate and usage_period are the fields I want to use parameters to run the report, therefore, I can run it without going in the workbook queries and edit the query and change it manually.

Someone can give me a hand on how to do this, will appreciate it. Thanks!




SELECT commodity, typerc, Usage_period, ProductType2
, SUM([MWhs/dth]) [sumOf_MWhs/dth]
, SUM(sumLineLoss) sumOf_sumLineLoss
, SUM(sumResidualUsageLoad) sumOf_sumResidualUsageLoad
, SUM(sumRemainingUsageLoad) sumOf_sumRemainingUsageLoad
, SUM(sumStorageCapacityPlan) sumOf_sumStorageCapacityPlan
, SUM(sumRemainingUsageLoad)+ SUM(sumStorageCapacityPlan) sumOf_NetLoad
FROM usage.vw_TLFSummary
WHERE 1=1
AND Commodity = 'e'
AND reportdate = '3/31/2017' -- END OF QUARTER
AND calc_method = 'Simple'
and Usage_period > '201703' -- END OF QUARTER MONTH
GROUP BY commodity, typerc, Usage_period, ProductType2


UNION ALL


SELECT commodity, typerc, Usage_period, ProductType2
, SUM([MWhs/dth]) [sumOf_MWhs/dth]
, SUM(sumLineLoss) sumOf_sumLineLoss
, SUM(sumResidualUsageLoad) sumOf_sumResidualUsageLoad
, SUM(sumRemainingUsageLoad) sumOf_sumRemainingUsageLoad
, SUM(sumStorageCapacityPlan) sumOf_sumStorageCapacityPlan
, SUM(sumRemainingUsageLoad)+ SUM(sumStorageCapacityPlan) sumOf_NetLoad
FROM usage.vw_TLFSummary
WHERE 1=1
AND Commodity = 'g'
AND reportdate = '3/31/2017' -- END OF QUARTER
AND calc_method = 'Simple (Est Delivery Req)'
and Usage_period > '201703' -- END OF QUARTER MONTH
GROUP BY commodity, typerc, Usage_period, ProductType2
ORDER BY commodity, typerc, Usage_period, ProductType2
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest

Forum statistics

Threads
1,216,081
Messages
6,128,696
Members
449,464
Latest member
againofsoul

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top