top of page

Swap Data Sources Dynamically Using Parameters in Power BI

hands typing on a keyboard

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...

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.

managing parameters in power BI

Configure your parameter details as follows.

configuring parameters in power bi

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”.

implementing the parameter in power bi

Replacing the data location with the parameter as follows.

replacing data location with a parameter in power bi to enable dynamic swapping of  data sources

Note, when you change the parameter value the data source changes.

For example, if I select “Production” on the parameter.

power bi parameter

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

sample dataset

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!

Original.png

We Support You Deliver Business-Focused Solutions That Enable Data-Driven Decision Making.

  • Tableau profile
  • YouTube
  • White LinkedIn Icon
  • Facebook
  • X

QUICK LINKS

CONTACT US

+254 738 307 495

East Gate Mall, Donholm

3rd Floor Suite No. 3i

Nairobi, Kenya

Join our mailing list

bottom of page