Forum Discussion
Execute Query from table in power bi
Hi,
I have a table that has several queries saved in a column as follows:
| ID | Query |
| 001 | Select top 10 * from table1; |
| 002 | Sleect top 10 * from table 2; |
and so on...
How can I get power bi to run these queries as direct query into snowflake and display the result data set via drill through ?
Any help is appreciated.
1 Reply
- danextian
Super User
Hi njohny
I don't think what you are tying to achieve is currently possible. Visuals are used to visualize the underlying data but not to send a query back to the database in away that you want it to. You can use parameters to affect a query (filter, change data source, etc) but there should already an existing query to affect them to.
As an alternative, you can:- bring in each SQL query as a data source, add an ID column to each containing their assigned ID and combine them all into one table in power query.
- bring in a table (you can use enter data, connect to an excel file saved locally or in the cloud, or connect to a google spreadsheet) containing a column for ID, server path, database name, table name, query, etc and use Sql.Database and those columns to bring in the desired data. That would be something like
Sql.Database([server path], [database name], [Query = [query column] ] )There are other ways to acces the desired table/views using the above method. This can be overwhelming id you're knew to Power BI but the flexibility allows one to have multiple ways to access a data source. Here's a documentation for this PQ function - https://learn.microsoft.com/en-us/powerquery-m/sql-databaseGoing back, the above alternatives still require that one start with a query to connect to a data source.
Note: Other users might have a better idea.