March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
Hello,
Is there any way to update server name and database name in power BI desktop by reading from a file, query or API?
After that data will be updated in Power BI desktop automatically.
Thanks
Nicki
Solved! Go to Solution.
You can use a query to pull that name in. Make it a scalar value - just right-click on the final result and Drill Down. That will show something as a text value. Rename the query to something like varServerName, and be sure to right-click on that and uncheck "Enable Load"
Then, in the actual query where you need this replace the server name with varServerName.
So:
= Sql.Database("Some_Server_Name", "DATA")
becomes
= Sql.Database(varServerName, "DATA")
Do the same with the database name.
You can see a bit more about this in my Dynamic Date Table post. I use the same logic to get a start and end date for a date table. Same concept, except you'll be getting a text value for a server name instead of a date value.
Creating a Dynamic Date Table in Power Query
DAX is for Analysis. Power Query is for Data Modeling
Proud to be a Super User!
MCSA: BI ReportingThis does NOT work on Power BI Report Server. This is amazingly frustrating.
You can reference an external Excel file for that. Let's say you have a SQL server and database source like:
Sql.Databases("DESKTOP-738NO1A\SQLEXPRESS")
If you have an excel file with a table with two columns: DataSource, Value
DataSource can be AdventureWorks, Value can be "DESKTOP-738NO1A\SQLEXPRESS".
Use Excel.Workbook to query the excel file, choose that table, right click the "cell' in which your "DESKTOP-738NO1A\SQLEXPRESS" resides. Nae that query something, like SQLSource.
Now, you can go back and change the source in AdventureWorks to SQL.Databases(SQLSource)
So now whenever you update that excel sheet, you are hanging the source as well--once you refresh they query.
---Nate
You can use a query to pull that name in. Make it a scalar value - just right-click on the final result and Drill Down. That will show something as a text value. Rename the query to something like varServerName, and be sure to right-click on that and uncheck "Enable Load"
Then, in the actual query where you need this replace the server name with varServerName.
So:
= Sql.Database("Some_Server_Name", "DATA")
becomes
= Sql.Database(varServerName, "DATA")
Do the same with the database name.
You can see a bit more about this in my Dynamic Date Table post. I use the same logic to get a start and end date for a date table. Same concept, except you'll be getting a text value for a server name instead of a date value.
Creating a Dynamic Date Table in Power Query
DAX is for Analysis. Power Query is for Data Modeling
Proud to be a Super User!
MCSA: BI ReportingMarch 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.