Forum Discussion
Dynamic database use
- 8 years ago
Hi Anonymous,
We can’t set dynamic connection to data source based on selected values in a slicer visual. But we can do it via Query Parameter feature.
Based on my test, you can refer to below steps:
1.Create a Parameter in query editor.
2.Get data from the SQL Server database and choose the Parameter.
3.Click “ok” and apply it. Now you select the different database by using the parameter.
Reference: http://biinsight.com/power-bi-desktop-query-parameters-part-1/
Regards,
Daniel He
- 8 years ago
Hello Anonymous,
I have similar use cases where I need to get data from 2 SQL Databases containing the same tables.
I know 2 simple ways to achieve what you're looking with SQL Databases1. Using Native query to unify the the tables and get source database as a column:
SELECT * , 'Database1' AS [Database] FROM Database1.schema.Table UNION ALL SELECT * , 'Database2' AS [Database] FROM Database2.schema.Table
2. Getting the 2 tables in power query, adding a custom field with the database (or desired) name as a value and appending them into 1 query:
1. Add a custom column by going to the Add Column tab in the Power Query Editor:
2. Repat for table 2
3. Appending queries
4. Visualize as you wish:
I hope that solves your issue!
Hi Anonymous,
We can’t set dynamic connection to data source based on selected values in a slicer visual. But we can do it via Query Parameter feature.
Based on my test, you can refer to below steps:
1.Create a Parameter in query editor.
2.Get data from the SQL Server database and choose the Parameter.
3.Click “ok” and apply it. Now you select the different database by using the parameter.
Reference: http://biinsight.com/power-bi-desktop-query-parameters-part-1/
Regards,
Daniel He
Hello Birdjo,
Thanks for sharing some approaches to solve this problem however I am going to stick with the solution given by v-danhe-msft, your answers were definitely a good answer to my question and I am sure I can make good use of this knowledge in the near future :)
Best regards, L.Meijdam