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
NHCC_IRE
Frequent Visitor

Report Server - Batch change of data source

We have two machines that run Report Server on them: one for production and one for development where the development server is a clone of the production server plus any development we are doing. Both machines also have SQL servers running on them with identical sets of data. Currently, all reports point to the production SQL server for data. However, as the number of reports has grown, we are starting to see report refresh slowdowns and reports getting stuck because the reports on both machines are refreshing at the same time using the same machine. We have manually shifted the refresh times on the development server to later to avoid this. However, a more satisfying solution would be that all the reports on the development server using the SQL server on the development server and not the production server. Does anyone know of any easy (e.g. SQL, Power Query, etc.)  way of changing the data source of many reports as a batch process to accomplish this? 

 

              - - - Andrew 

1 ACCEPTED SOLUTION
Icey
Community Support
Community Support

Hi @NHCC_IRE ,

 

Bsed on my knowledge, it is not supported to change the data source directly without open the .pbix file. Please try to create query parameter like what @d_gosbell mentioned.

 

Or, maybe you can also try to store your connection string to a config file, then write a custom function to analysis this file. After these steps, you can change the datasource without open the pbix file.(After you modified the config file, you should refresh it at pbix report to get the newest data).

 

Sample:

let
xmlTable = Xml.Tables(File.Contents("C:\Users\xxxxx\Desktop\test.xml")),
server=xmlTable[Server]{0},
database=xmlTable[Database]{0},
Source= Sql.Database(server,database)
in
Source

 

Xml:

<config>
<Server>"abc"</Server>
<Database>"edd"</Database>
</config>

Screenshots:

Icey_0-1649146021171.png

 

 

Reference: Solved: Re: Change pbix data source programmatically - Microsoft Power BI Community

 

 

 

Best Regards,

Icey

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
Icey
Community Support
Community Support

Hi @NHCC_IRE ,

 

Bsed on my knowledge, it is not supported to change the data source directly without open the .pbix file. Please try to create query parameter like what @d_gosbell mentioned.

 

Or, maybe you can also try to store your connection string to a config file, then write a custom function to analysis this file. After these steps, you can change the datasource without open the pbix file.(After you modified the config file, you should refresh it at pbix report to get the newest data).

 

Sample:

let
xmlTable = Xml.Tables(File.Contents("C:\Users\xxxxx\Desktop\test.xml")),
server=xmlTable[Server]{0},
database=xmlTable[Database]{0},
Source= Sql.Database(server,database)
in
Source

 

Xml:

<config>
<Server>"abc"</Server>
<Database>"edd"</Database>
</config>

Screenshots:

Icey_0-1649146021171.png

 

 

Reference: Solved: Re: Change pbix data source programmatically - Microsoft Power BI Community

 

 

 

Best Regards,

Icey

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

d_gosbell
Super User
Super User

You could try this technique using Parameters in your Power Query code then changing them with a PowerShell script https://docs.microsoft.com/en-us/power-bi/report-server/connect-data-source-apis 

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.

Top Solution Authors