Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

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 ...
  • v-diye-msft's avatar
    v-diye-msft
    7 years ago

    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

     

    Then add another new query to get the table 2 :

    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.