Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Anonymous
Not applicable

Change parameter of data source in Advanced Editor

Hello guys,

 

In my project, we have 2 environments Development and Production which should have same data tables with same columns, only data change. These environments are in 2 differents instances of SQL SERVER thus once the development of the PIBX is done, I will have to change the data source parameters to link to the PROD( switch from the Dev environment to the Prod environment). It avoid to do all data transformation again

 

For that, I have done a test : create a same table in these environments and a PIBX which is linked firstly to the Dev with some data transformation ( head-column name changed & data type changed). After, I opened the Advanced Editor in Power Query to change parameters of the data source like below :

-------------------------------------------------------------------------------------

//DEV

 let
Source = Sql.Databases("DEV"),
dev_instance = Source{[Name="dev_instance"]}[Data],
dbo_Table_Test_T = dev_instance{[Schema="dbo",Item="Table_Test_T"]}[Data],
#"Type modified" = Table.TransformColumnTypes(dbo_Table_Test_T,{{"Date_1", type date}, {"Date_2", type date}}),
// Change DR - Unity
// Date_1 - Start Date
// Date_2 - End Date
//
#"Column renamed" = Table.RenameColumns(#"Type modified",{{"Date_1", "Start Date"}, {"Date_2", "End Date"}, {"DR", "Unity"}})
in
#"Column renamed"
-------------------------------------------------------------------------------------
To link the PROD :

-------------------------------------------------------------------------------------

//PROD

let
Source = Sql.Databases("PROD"),
prod_instance = Source{[Name="prod_instance"]}[Data],
dbo_Table_Test_T = prod_instance{[Schema="dbo",Item="Table_Test_T"]}[Data],
#"Type modified" = Table.TransformColumnTypes(dbo_Table_Test_T,{{"Date_1", type date}, {"Date_2", type date}}),
// Change DR - Unity
// Date_1 - Start Date
// Date_2 - End Date
//
#"Column renamed" = Table.RenameColumns(#"Type modified",{{"Date_1", "Start Date"}, {"Date_2", "End Date"}, {"DR", "Unity"}})
in
#"Column renamed"

-------------------------------------------------------------------------------------

 

After this change, all the data transformation still have worked because the name of the data table and the name of columns are the same between the environments. Mission accomplished however, it is the first time for me so I don't know if this way is a good pratice.

 

What do you think ? Do you have some advices,recommandations to improve? Do I need to use parameters ?

 

Thank you very much and have a good day !

4 REPLIES 4
mohammedadnant
Impactful Individual
Impactful Individual

Hi @Anonymous 

 

Good day,

 

That is the normal method and it is fine, few other methods are

1. Use parameters as you said

2. You can use Data Source settings (if all the table are from same Dev to Prod)

mohammedadnant_0-1616065791475.png

here you can change the data source settings and it will change to all the tables in 1 go

3. if you have premium or premium per user licence you can use deployment pipeline, refer this video

https://youtu.be/XtEMSmr1TEY

 

Thanks & Regards,

Mohammed Adnan

Did I answer your question? Mark my post as a solution! Appreciate your Kudos!! !!

Thanks & Regards,
Mohammed Adnan
Learn Power BI: https://www.youtube.com/c/taik18
Anonymous
Not applicable

do it work with Power BI Pro ?

amitchandak
Super User
Super User

@Anonymous , You can use parameter

refer: https://radacad.com/change-the-source-of-power-bi-datasets-dynamically-using-power-query-parameters

 

video from guyinacude

https://www.youtube.com/watch?v=XIq5vN5oPf8

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Hi

thank you for the solution !

 

I have Power BI RS and I found the behavior is really strange.

 

I think the parameter works on Server field but not on the Database field. When I change the value of the parameter for the server, the power query update it but it's not the case for the database. For the database, I noticed that the Power Query take the name of the parameter to put it in the information of the data source instead of taking its VALUE. So to make it works, I changed directly the name of the parameter so its value is useless

 

It's because of the version of Power BI ?

Capture.PNG

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.