Microsoft is giving away 50,000 FREE Microsoft Certification exam vouchers. Get Fabric certified for FREE! Learn more
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.
Solved! Go to 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:
Regards,
Xiaoxin Sheng
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.
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
Check out the April 2025 Power BI update to learn about new features.
Explore and share Fabric Notebooks to boost Power BI insights in the new community notebooks gallery.
User | Count |
---|---|
106 | |
68 | |
48 | |
44 | |
42 |