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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Changing the Power query SQL Server database settings when moving an Excel workbook

HIi

 

I'm working on creating an excel report that collects data from a local copy of a SQL Server database on my maschine, where I use Power Query to retrieve the data. These are then loaded into a PowerPivot data model. Now I'm finished with the development and on my way to put this into production on another server on the customer's server. The Excel workbook must change database settings using sql server database user Connection (not integrated). I had hoped that I could change the database Connection Properties at the Data tab, but there are not any easy way to change the connection string to the new server. Now I can't see any option that going through every Power Query query and change them manually. I have great hope that you Power Query experts have a Nice explaination and an example how I can solve this.

Regards Geir F

1 ACCEPTED SOLUTION
v-shex-msft
Community Support
Community Support

Hi @Anonymous,

 

You can refer to below method: use custom function and query parameters to load data.

 

Custom function:

 

let
    Custom= (ServerName as text,DataSource as text, SQLQuery as text) as table=>
    let
        Source = Sql.Database(ServerName, DataSource,[Query=SQLQuery])
    in
        Source
in
    Custom

 

 

Parameters:

 

Capture.PNG

 

Use:

let
    Source = LoadData(ParaServerName,ParaDataSource,ParaQuery)
in
    Source

 

Capture2.PNG

 

After above steps, you can modify the parameters to change the datasource.

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

2 REPLIES 2
v-shex-msft
Community Support
Community Support

Hi @Anonymous,

 

You can refer to below method: use custom function and query parameters to load data.

 

Custom function:

 

let
    Custom= (ServerName as text,DataSource as text, SQLQuery as text) as table=>
    let
        Source = Sql.Database(ServerName, DataSource,[Query=SQLQuery])
    in
        Source
in
    Custom

 

 

Parameters:

 

Capture.PNG

 

Use:

let
    Source = LoadData(ParaServerName,ParaDataSource,ParaQuery)
in
    Source

 

Capture2.PNG

 

After above steps, you can modify the parameters to change the datasource.

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
Anonymous
Not applicable

Hello again.

 

Take a look at suggested method above. If I want to set a SQL SERver authentication together with servername, user name and password, how will these 3 parameters look like?

 

regards GEir F

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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