Excel Parameters in Power Query
Some models need a value chosen in the workbook, such as a date or a region, to control what a query returns. This page shows how to pass a value from an Excel cell into Power Query, where it is used as a variable inside another query.
The example: orders for one date
Section titled “The example: orders for one date”The source is a table of orders, with an order date, an order number, a quantity and a unit price on each row. The aim is to type a date into one cell in Excel and have the query return only the orders placed on that date whenever it is refreshed.

1. Hold the parameter in a table
Section titled “1. Hold the parameter in a table”- Create a table with one column and one row, which holds the date of the orders to return.

- Click inside the table, and then click From Table/Range on Excel’s Data tab.

The table opens in the Power Query Editor as a table with a single cell. A filter cannot compare a column with a table, so the date has to be taken out of it:
- Right-click the cell and choose Drill Down.

The query now returns the date on its own, as a single value rather than a table.

Because the query returns a single value, its name can be used directly inside another query. In this example the query is named Parameter.
2. Filter the orders on any date
Section titled “2. Filter the orders on any date”Next, build the query that returns the orders.
- Load the order data into the Power Query Editor.
- Open the drop-down on the Order Date column and filter it on any one date.

Power Query adds a step that filters on the date chosen, which is written into the step’s code as a fixed value.
![The formula bar showing Table.SelectRows with the condition [Order Date] = #date(2011, 1, 2), above the five orders dated 02/01/2011](/_astro/excel-parameters-pq-7.CNiHXNFb_Z1YHAtg.webp)
3. Point the filter at the parameter
Section titled “3. Point the filter at the parameter”- In the formula bar, replace the fixed date with the name of the parameter query.

- Choose Close & Load, so that the query loads to the worksheet.

- To test it, change the date in the parameter table and refresh the query.
The loaded table now holds only the orders placed on the new date.
