
Overview
This method is useful when you have the same data structure in different environments, databases, or folders. By using parameters, you can change the source without needing to edit your Power BI file. Additionally, this approach can be used to switch connections between development, testing, and production environments without making numerous changes to the source code.
In this short article, I am going to demonstrate how to use parameter to swap data sources between Testing and Production environments (folders).
In this example, I am working with an excel file “Store_Data” saved into two folders namely testing and production. Note, the two datasets have same structure but different values.
Using a Parameter, I am going to demonstrate how you can swap your connection dynamically from one dataset to another between the two folders (environments).
To do so, I am going to connect the Store_Data from the Testing folder to Power BI.
Once the dataset is connected open the Power Query Editor...

Note: The current connection has three columns and five rows.
Create a parameter by going to Manage Parameters then New Parameter as shown below.

Configure your parameter details as follows.

In this example, I have named my parameter “Data_Source”, set the data type as Text, where I have set suggested values as list of values in this case “Testing” & “Production” (which are basically the locations of my datasets).
To implement the parameter.
Go to the source step and replace the data location “Testing” environment with the above parameter named “Data_Source”.

Replacing the data location with the parameter as follows.

Note, when you change the parameter value the data source changes.
For example, if I select “Production” on the parameter.

The data source automatically changes from testing environment which had five rows to production environment which has 10 rows as shown below.

Conclusion
Using parameters to swap data sources in Power BI not only simplifies the management of different datasets but also promotes a more agile development process. This method allows teams to work efficiently across various environments while maintaining data integrity and consistency.
If you like the work we do and would like to work with us, drop us an email on our contacts page and we’ll reach out!
Thank you for reading!