Parameters
Power BI · Getting Data
Theory
Power Query parameters are named values, such as a server name, file path, date or number, that queries can reference instead of hard-coded text. You create them in Manage Parameters, give each a name, type and current value, and then use the name in steps or in connector dialogs. Changing the parameter value changes every query that uses it.
For example, a parameter ServerName with value sql-dev-01 is used in Sql.Database(ServerName, "SalesDB"). When the report moves to production you change ServerName to sql-prod-01, either in Desktop or in the Service under the semantic model's settings, and all three tables now load from production. Parameters are also how incremental refresh works: it requires two Date/Time parameters named RangeStart and RangeEnd.
Why we use it
Hard-coded paths and server names make reports break when moving between developer machines and environments. Parameters put those values in one place so switching from Dev to Prod is a single change.
When to use it
Use parameters for anything that differs between environments or users: servers, databases, folder paths, row limits during development. They are not a replacement for report slicers, which filter data for viewers at run time.
How it works
- Value repeats in several queries
- Home → Manage Parameters → New Parameter
- Set name, type and current value
- Replace hard-coded text with the parameter
- Moving to another environment? Yes: Change the parameter value and refresh. No: Keep the current value.
- All dependent queries update together
Syntax
Home → Manage Parameters → New Parameter (Name, Type, Suggested values, Current value)
Use: in a connector dialog choose 'Parameter' instead of 'Text', or reference the name in M
Service: semantic model → Settings → ParametersExample
// Parameter query 'ServerName' (created via Manage Parameters)
"sql-dev-01" meta [IsParameterQuery = true, Type = "Text", IsParameterQueryRequired = true]
// Sales query uses it
let
Source = Sql.Database(ServerName, "SalesDB"),
Sales = Source{[Schema = "dbo", Item = "Sales"]}[Data]
in
Sales
// Deploying to Prod: change ServerName to "sql-prod-01"; Sales, Customers and Products all follow.Key points
- Parameters have a name, type and current value
- Reference them in M or select them in connector dialogs
- Can be changed in the Service without editing the .pbix
- Incremental refresh needs RangeStart and RangeEnd Date/Time parameters
- Parameters configure queries; slicers filter for viewers