Ravindra BagaleCourses & study guides

10. Parameters in Power Query (and Other Kinds of Parameters)

10.4 Parameterising Server and Database (Dev → Prod)

Steps in Power BI

  1. Create ServerName (Text, List of values: QCTEST01, QCSERVER01; current QCTEST01) and DatabaseName (Text: QuickCommerceDB).
  2. Open Advanced Editor for each SQL query and replace the hard-coded names (code below).
  3. Build and test the report against QCTEST01.
  4. Before publishing, switch ServerName to QCSERVER01 (Edit parameters) › refresh › publish.
  5. In the Service, open the semantic model Settings › Parameters to change values there too. The gateway must have a connection for each server you use (Module 4.8).
Source = Sql.Database(ServerName, DatabaseName),
Orders = Source{[Schema = "dbo", Item = "Orders"]}[Data]

Ravindra Bagale's Tip

Remember one thing: the mistake I see is changing server names by editing every query by hand when moving from Dev to Prod. Use one ServerName and one DatabaseName parameter for all queries. In the Service, change them in the semantic model settings or with deployment rules. Remember this rule.