Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Excel Power Query Parameter from Cell

· 5 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

To use a cell value as a parameter in Power Query, you create a named range or a table for that cell, then reference it in your query using Excel.CurrentWorkbook(). This lets you change the parameter without editing the query—just type a new value in the cell and refresh. You'll need Excel 2016 or later (or Microsoft 365) with Power Query built in.

What You'll Need

  • Excel 2016 or later (Power Query is built into the Data tab; if you don't see it, you may need to install the Power Query add-in for Excel 2013/2010).
  • A worksheet with the cell you want to use as a parameter (e.g., a file path, a date, a product name).
  • Basic familiarity with the Power Query Editor (opening it from Data > Get Data).

Step-by-Step

  1. Set up your parameter cell. Decide which cell will hold the parameter. For clarity, put a label in the cell to its left (e.g., "Folder Path" in A1, value in B1).
  2. Create a named range for the cell. Select the cell (e.g., B1), go to Formulas > Define Name. Give it a simple name like ParamFolder or ParamDate. Make sure the "Scope" is "Workbook" (default). Click OK.
  3. (Alternative) Convert the cell to a table. If you prefer a table (useful when you have multiple parameters), select the label and value cells (e.g., A1:B1), then press Ctrl+T to create a table. Name the table something like tParams in the Table Design tab.
  4. Open Power Query. Go to Data > Get Data > From Other Sources > Blank Query. This opens the Power Query Editor.
  5. Create a query that reads the cell. In the editor, go to Home > Advanced Editor. Replace the default code with: let in Source If you used a table instead, the code is: let in Source (Adjust the column name if your table has a header—if so, use [Value] instead of [Column1] .)
  6. Name this query as your parameter. In the Query Settings pane on the right, rename the query to something like ParamFolder. This makes it easy to reference later.
  7. Load the parameter query (optional but recommended). By default, this query will load to a worksheet. You can avoid that by right-clicking the query in the Queries pane and unchecking "Enable load". This keeps it as a pure parameter.
  8. Use the parameter in another query. Create a new blank query (or edit an existing one). In the Advanced Editor, reference the parameter query by name. For example, to get data from a folder path stored in the cell: let Source = Folder.Files(ParamFolder) in Source Or for a date parameter: let Source = Sql.Database("server", "db"), dbo_Table = Source{[Schema="dbo",Item="Table"]}[Data], in Filtered
  9. Refresh to apply changes. After changing the value in the parameter cell, go to Data > Refresh All. Power Query will re-read the cell and update the results.

Common Mistakes

  • Using a direct cell reference like B1 in the query. Power Query cannot see cell references directly; you must use a named range or table.
  • Forgetting to refresh after changing the cell. The query won't update automatically unless you refresh (or set the workbook to refresh on open).
  • Naming the named range with spaces or invalid characters. Use only letters, numbers, underscores, and periods; start with a letter or underscore.
  • Loading the parameter query to a worksheet. This creates an extra table on your sheet that can confuse users. Disable load if you don't need it.
  • Using a table but referencing the wrong column. If your table has headers, the column name is the header text, not "Column1".

Tips

  • Use a dedicated Parameters sheet. Keep all parameter cells together on one sheet, with clear labels, so users know where to edit.
  • Use data validation on the parameter cell. Restrict input to a list of valid options (Data > Data Validation) to prevent errors.
  • Name your parameter queries with a prefix like Param. This makes them easy to spot in the Queries pane.
  • For multiple parameters, use a table. A two-column table (Parameter Name, Value) is easier to maintain than many named ranges.
  • Test with a simple query first. Create a parameter that returns the value itself, then load it to a cell to confirm it reads correctly before using it in complex queries.

Troubleshooting

  • Error: "We couldn't find an object named 'ParamFolder'." This means the named range doesn't exist or the name is misspelled. Check Formulas > Name Manager. If you used a table, ensure the table name is correct.
  • Error: "Expression.Error: The column 'Column1' of the table wasn't found." This happens when your table has headers. Use the actual column header (e.g., [Value]) instead of [Column1].
  • The parameter cell is empty or shows 0. Power Query reads the cell as a single-column table. If the cell is empty, the query returns null. Make sure the cell contains a value before refreshing.
  • Changes to the cell don't affect the query. You must refresh. Also, if you have "Enable load" disabled, the query still refreshes when you click Refresh All, but you won't see the parameter value on the sheet—check the query output indirectly.
  • Power Query is grayed out. This can happen if your Excel version doesn't include it (e.g., Excel 2007). Upgrade to Microsoft 365 or install the Power Query add-in.

Frequently Asked Questions

Can I use a cell value as a parameter without creating a named range?

No. Power Query cannot reference a cell directly. You must create a named range or a table for that cell.

Will my query update automatically when I change the cell?

Not automatically. You need to refresh (Data > Refresh All). You can set the workbook to refresh on open in Connection Properties.

Can I use multiple parameters from different cells?

Yes. Create a named range for each cell, or use a table with multiple rows (one per parameter). Then reference each in your queries.

How do I use a parameter in a SQL query?

In the Power Query Editor, when you create a SQL query, you can reference the parameter query by name. For example, Sql.Database("server", "db") then filter with each [Column] = ParamValue.

Can I use a cell value as a parameter for a folder path?

Yes. That's a common use case. Create a named range for the folder path cell, then use Folder.Files(ParamFolder) in your query.

What if my parameter is a date or number?

Power Query will read the cell value as the correct data type if the cell is formatted as date or number. If not, you may need to convert it in the query using Date.From or Number.From.