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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Multiple Databases with the same Data Source

Hi Guys,

 

I'm intrested in building a report based on multiple databases using the same data source.

I found some leads in the forums, but with no luck to the below.

 

Data source - SQL Server - single gateway

The DB list is based on a dynamic query, i have a list of them in a table called Companies (Select DBName from MainServer.dbo.Companies)

Query - Select * from [DynamicDB].dbo.Transactions

After that, I need to append them all to each other.

 

Any help will be appreciated!

 

PS, i tried using parameters (Server Name and DB), but I couldn't get more then one DB at a time.

 

Regards,

E.

 

 

 

1 ACCEPTED SOLUTION

Hi @Anonymous ,

 

I got your point and tried to set the query table dynamically:

1. In query editor pane, New source>SQL server> "Servername" (Keep database name as empty) > IM mode> select one table > Ok, then delete the Navigation step. you'll get the list of database in the first column. 

2. Right click the column > Add as new query

3. Then create the parameter based on the query, everytime you refresh the data source, the list will be updated,  we can fetch the data in different DB by switching parameter value.

But the problem is One parameter works for One database, and fetch one table under it:(DB is the parameter name)

let
    
    Source = Sql.Databases("MININT-8GMT4UN\SQLEXPRESS"),
    DB = Source{[Name= DB]}[Data]
in
    DB

You can select the specific table under the database, and final one is Table1

005.PNG

 

Then add another new query to get the table 2 :

006.PNG

Then we can use the M code to append Table1 with Table2 as new table, (Notes Table1 and Table2 are dynamically changing when we switch the parameter).

let
    Source = Table.Combine({Table_1, Table})
in
    Source

Please let me know if it works for you.

 

 

Community Support Team _ Dina Ye
If this post helps, then please consider Accept it as the solution to help the other members find it more
quickly.

View solution in original post

5 REPLIES 5
v-diye-msft
Community Support
Community Support

Hi @Anonymous ,

 

1. You can use desktop to connect several database under same server. Get data > SQL server both Import and DQ mode work well.

2. Use dataflow in power bi service , it even allow combining several data source. Official document refers to: https://docs.microsoft.com/en-us/power-bi/service-dataflows-create-use

 

 

Community Support Team _ Dina Ye
If this post helps, then please consider Accept it as the solution to help the other members find it more
quickly.
Anonymous
Not applicable

Thanks for the reply @v-diye-msft ,

 

Maybe I'm missing something, but I don't understand how your proposed solution is dynamic.

In my scenario, I don't want to address each source and manually concatenate it with the other sources.

 

BR,

Eliran.

Hi @Anonymous 

 

You can add the databse list in the parameter:

002.PNG

Then connect the SQL server using the current Databse, after fetching the data, then change the database:

003.PNG

Then try again: Get data>SQL server, both connection mode are fine. then you'll get the data from different databse.

 

 

 

Community Support Team _ Dina Ye
If this post helps, then please consider Accept it as the solution to help the other members find it more
quickly.
Anonymous
Not applicable

Thanks again @v-diye-msft ,

 

I already tried the parameter approach, but it doesn't seem to answer my specific need.

Let's say that today I got 2 DB's, so my flow is:

  1. define the DB's in the list
  2. set first DB - fetch data
  3. set second DB - fetch data
  4. append the two into one table

Tomorrow, I'll have 10 DB's, should I manually redo all the steps? how is the parameter helps me?

My idea was a defining a loop that will do the steps dynamicly:

for each db in list

  • query table
  • append

end loop

I just can't seem to understand how to implement it.

 

Regards,

Eliran.

Hi @Anonymous ,

 

I got your point and tried to set the query table dynamically:

1. In query editor pane, New source>SQL server> "Servername" (Keep database name as empty) > IM mode> select one table > Ok, then delete the Navigation step. you'll get the list of database in the first column. 

2. Right click the column > Add as new query

3. Then create the parameter based on the query, everytime you refresh the data source, the list will be updated,  we can fetch the data in different DB by switching parameter value.

But the problem is One parameter works for One database, and fetch one table under it:(DB is the parameter name)

let
    
    Source = Sql.Databases("MININT-8GMT4UN\SQLEXPRESS"),
    DB = Source{[Name= DB]}[Data]
in
    DB

You can select the specific table under the database, and final one is Table1

005.PNG

 

Then add another new query to get the table 2 :

006.PNG

Then we can use the M code to append Table1 with Table2 as new table, (Notes Table1 and Table2 are dynamically changing when we switch the parameter).

let
    Source = Table.Combine({Table_1, Table})
in
    Source

Please let me know if it works for you.

 

 

Community Support Team _ Dina Ye
If this post helps, then please consider Accept it as the solution to help the other members find it more
quickly.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors
Top Kudoed Authors