By default, when data is imported to the PowerBI Desktop, each table or query stores data source details separately, even if they use the same data source.
This makes it tedious, for example, to change the source database of an entire PowerBI report - which requires changing each query source parameter individually.
There is a way to simplify this, described here.
Import your data as you normally would. Example:
data source type - SQL server,
server name - localhost
,
database - test1
,
tables - table1
, table2
.
In query editor, add two blank queries: "Get Data" -> "Blank Query",
serverName
with value = "localhost"
,
databaseName
with value = "test1"
.
For each table on the "Queries" pane on the left, select "Source" in "Query Settings" on the right, then substitute server and database names with parameters created in the step 2.
Now when you need to update your connection string, change serverName
or databaseName
and refresh data.