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

Microsoft is giving away 50,000 FREE Microsoft Certification exam vouchers. Get Fabric certified for FREE! Learn more

Reply
JorgeDiego
Advocate I
Advocate I

Change pbix data source programmatically

Hi everyone,

 

I want to know wheter is it possible to change the data source from a pbix file programmatically. 

I want to use the same report for different customer that use different data bases, with the same schema. 

 

Currently, I develop a report using an internal data base and then I change this report data source for every customer and I upload the pbix file to them power bi account. So, what I want to do is to make this process programmatically to do it faster and avoid possible errors. 

 

Thanks in advance.

1 ACCEPTED SOLUTION

Hi @JorgeDiego,

 

As you said, power bi not support to direct modified the datasource without open the pbix file, perhaps you can submit your requirement to ideas.


In addition, you can 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:

 

Capture.PNG

 

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

22 REPLIES 22
hugoberry
Responsive Resident
Responsive Resident

Using parameters as @v-shex-msft was mentioning plus think about storing a file with connection string as its contents and store it in the same location for each of the client. Then on opening the PBIT the parametrs can be prepopulated with the contents of this stored file.

 

Otherwise you can think about a more (Power Query M) scripted approach where you parse PBIX/PBIT files, extract the query scripts do the replacements and figure out how to re-save that as a new PBIX/PBIT file.

v-shex-msft
Community Support
Community Support

Hi @JorgeDiego,

 

You can take a look at below link which about use parameterized power query function to load the data source:

 

Deep Dive into Query Parameters and Power BI Templates

 

Regards,

Xiaoxin Sheng

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

Helpful resources

Announcements
Notebook Gallery Carousel1

NEW! Community Notebooks Gallery

Explore and share Fabric Notebooks to boost Power BI insights in the new community notebooks gallery.

April2025 Carousel

Fabric Community Update - April 2025

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

Top Solution Authors