Power Query Parameters: A Practical How-To
In this article
Power Query parameters are named values you define once and then reference inside your queries instead of hard-coding things like a file path, server name, date or filter value. Change the parameter, refresh, and every query that uses it updates. To do this you create the parameter through the Manage Parameters dialog in the Power Query Editor, then replace the hard-coded value in a query step with a reference to that parameter — for example swapping a fixed folder path in the Source step for a parameter called FolderPath. This guide uses Excel and Power BI Desktop, where the feature lives in the same place; the labels can differ slightly by version, so read the closest match on screen.
What You'll Need
- A copy of Excel (Power Query is built in under the Data tab) or Power BI Desktop, both up to date.
- An existing query that already loads the data you want to parameterise, or permission to create one.
- Know the exact value you want to make dynamic — a folder path, a server and database name, a start date, a list of allowed values.
- For file or folder parameters, access to the shared location, since credentials are stored per connection and not per parameter.
Step-by-Step
- Open the Power Query Editor. In Excel, select any cell in your data and go to Data > Get Data > Launch Power Query Editor. In Power BI Desktop, use Home > Transform data. The editor opens in its own window.
- In the editor, go to Home > Manage Parameters > New Parameter. The Manage Parameters dialog also has a drop-down arrow; choosing New Parameter opens the same form.
- Fill in the form. Give the parameter a Name with no spaces if you can (underscores are fine, for example
SourceFolder), choose a Type such as Text, Date, Decimal Number or Logical, and enter a Current Value. For a folder path, type the full path without a trailing backslash. Leave Required ticked unless you genuinely want the parameter to be optional. - If you want the user to pick from a fixed list, tick Suggested Values and choose List of values (type the options one per line) or Query (point at a small table of allowed values). This matters later: a parameter with a suggested-values list becomes a drop-down in the filter pane and in the Excel dialog.
- Select OK. The parameter appears as a query on the left, marked with a parameter icon. It has no data — it is just a stored value.
- Now open the query that should use it. Find the step in Applied Steps that contains the hard-coded value. For a folder source, that is the Source step holding the old path; for a server, it is the database Source step; for a date filter, it is the Filtered Rows step.
- Click that step so its M code shows in the formula bar, then replace only the quoted literal with the parameter name — no quotes around it. For example change
= Folder.Files("C:\Data\Sales")to= Folder.Files(SourceFolder). Press Enter. The step re-runs with the parameter value. - If the replacement errors, undo it and try editing through the UI instead: right-click the step and use the relevant replace/insert dialog, or edit the value in the step's own dialog box and swap in the parameter where the dialog offers it.
- Repeat for every query that shares the same value. One parameter can drive many queries; that is the whole point.
- Test: change the parameter's Current Value via Manage Parameters, select the parameter, edit the value, and choose OK. Then Home > Refresh Preview. If all dependent queries update cleanly, the wiring is correct.
- Load the result. In Excel, Home > Close & Load. In Power BI, Home > Close & Apply. You can then change the parameter value without reopening the editor, using the parameter's dialog in Excel or the Edit parameters control in Power BI, then refreshing.
Common Mistakes
- Quoting the parameter. Writing
Folder.Files("SourceFolder")passes the literal text "SourceFolder" to the function, not the value. Parameter names in M are unquoted. - Renaming the parameter afterwards. Renaming a parameter does not rewrite references in queries it already feeds, so previously working steps break. Decide the name early, or fix references by hand after renaming.
- Wrong data type. A date parameter typed as Text will not compare correctly against a date column and the filter will fail or return nothing. Match the parameter type to the column type.
- Trailing backslash on folder paths. Many folder functions dislike a trailing separator; strip it.
- Credential confusion. Parameters change the path, but the stored credentials belong to the connection. A parameter pointing at a new server may prompt for credentials or fail silently on scheduled refresh until you update them in the data source settings.
Tips
- Create a parameter for anything that changes regularly — month-end folders, test versus production server names, report start dates — before you build queries, so you do not retrofit later.
- Keep a small table of values in the workbook or model and drive a Query-based parameter from it; this is the standard way to build a clean drop-down selector.
- Add a comment above a complex Source step so the next person knows which parameter feeds it.
- Group parameters together by right-clicking them and using Move To Group, which keeps the Queries pane readable.
- Give parameters meaningful names like
SalesFolderPathrather thanParam1; you will read them in code more often than you expect.
Troubleshooting
If a query fails after you add a parameter, open the failing step and check the formula bar first: most errors are a stray pair of quotes, a typo in the name, or a type mismatch. Compare the parameter's Type against the column or argument it feeds.
If the query refreshes but returns nothing, the parameter is probably valid but pointing somewhere empty — an old folder, a deleted file, a filter value with no matches. Change the Current Value and refresh the preview to confirm.
If a scheduled or background refresh fails while a manual refresh works, the credential store is the likely culprit: sign in again through the data source settings, or re-enter credentials for the new location.
If the parameter has disappeared from the filter pane or the Excel picker, it likely lost its Suggested Values list. Reopen Manage Parameters and re-tick Suggested Values.
If nothing helps, duplicate the query, delete the parameter, and recreate both from scratch — that clears stale code that is hard to spot by eye. As a last resort, clear the query's cached data and refresh; you lose only cached results, not the query itself.
Frequently Asked Questions
Can the same parameter be used in more than one query?
Yes. That is the main reason to use one: change the value once and every query referencing it updates on refresh.
Can I edit a parameter without opening the Power Query Editor?
Yes. In Excel there is a parameter dialog on the Data tab once a parameter exists, and in Power BI Desktop the query's parameters can be edited from the model view. The exact control name varies by version.
Do parameters work with scheduled refresh?
Yes, provided the stored credentials remain valid for whatever the parameter points at. If the path or server changes, re-enter credentials.
What is the difference between a parameter and a query that returns one value?
A query that returns a single cell gives you a value you can reference, but only a parameter gets its own picker, typed validation and suggested values. Use a parameter when a person will change it.
Can a parameter contain a list of values?
Promoted values can hold a list, but the common pattern is a text parameter filtered against a table of allowed values, which behaves predictably in the filter pane.
Why does my date parameter filter return wrong results?
Almost always a type mismatch — the parameter is Text or DateTime while the column is Date. Set the parameter type to match the column and refresh.