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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
Anonymous
Not applicable

Using a Txt or XML-File as source-path-replacement

Hi everyone,
I'm trying for days now ..

I have to figure out how to make our pbix files neutral.
Leaving everything as it is, except the https-connectionstring. I found the hint here using a xml-file but I really don't know how to use it. 
Did anyone face the same issue? 

My source looks like this before the changes:

let

    Source = Json.Document(Web.Contents("https://xxx.xxx.com/xxx/api/xx/xxx/")),

    #"In Tabelle konvertiert" = Record.ToTable(Source)

in

    #"In Tabelle konvertiert"

 

And I would like to use it like this, so that we could just save a file for every customer:

 

Source = File.Contents("C:\Users\xxxx\x\Dokumente\Config.txt")
or
Source = File.Contents("C:\Users\xxxx\x\Dokumente\Config.xml")

 

 

Power BI can open the file but that is not what I need. I want it to use the content and replace the space after Source.


Please excuse my bad English. I hope someone can help.

Thank you in advence
P.S. I am not the one working with Power BI. Just the person who has to figure out how to fix this problem.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous ,

Current query table not allow you to use same step name, I share the test query below.

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>

In addition, can you please share your xml data structure so that I can modify my query to analysis correspond parameters.

Regards,
Xiaoxin Sheng

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Hi @Anonymous ,

Yes, it is possible. You can direct refer value from another query table.
BTW, power query tables not support dynamic data structure, you need to confirm they have same structure before change connection string.

Reference:

Change pbix data source programmatically

Regards,

Xiaoxin Sheng

Anonymous
Not applicable

Hi @Anonymous ,
Thanks for the quick answer. 
Unfortunatly I am missing a few informations to understand and replicate this solution. 

You reffered to an older post, which I already tried... 

 

What does this xml has to look like?

I cannot use "Source" twice in my code... can I?

 

let
    Source = Xml.Tables(File.Contents("C:\Users\xxxxx\Desktop\Config.xml")),
    Table0 = Source{0}[Table],
    #"Changed Type" = Table.TransformColumnTypes(Table0,{{"Attribute:name", type text}, {"Attribute:connectionString", type text}}),
    #"Renamed Columns" = Table.RenameColumns(#"Changed Type",{{"Attribute:connectionString", "ConnectionString"}}),
    Custom= List.First(Table.SelectRows(Table.SelectColumns(#"Renamed Columns","ConnectionString"), each [ConnectionString] <> null)[ConnectionString]),
    connectString=Text.Split(Text.Replace(Text.Replace(Custom,"server = ",""),"data source=",""),";"),
    Name= List.First(connectString),
    ConnectString= List.Last(connectString)),
    Source= //invoke data connection method here       ----- 
in
    Datasource


Thanks in advance

Anonymous
Not applicable

Hi @Anonymous ,

Current query table not allow you to use same step name, I share the test query below.

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>

In addition, can you please share your xml data structure so that I can modify my query to analysis correspond parameters.

Regards,
Xiaoxin Sheng

Anonymous
Not applicable

Hi @Anonymous ,

Now I got it! Thank you very much! 

My xml-structure isn't more than this. But it works just fine 🙂 
To use the URI you have to write it without ""

<config>
<Server> https://connection.com/xxx/xxx/ </Server>
</config>

Thats the Power Query

let
xmlTable = Xml.Tables(File.Contents("C:\Path\Config.xml")),
#"Changed Type" = Table.TransformColumnTypes(xmlTable,{"Server", type text}), 
server = xmlTable[Server]{0},
Source = Json.Document(Web.Contents((server)))
in
Source

Regards
Kathrin

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.