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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch 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

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here
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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.