Forum Discussion
How can I replace a table or view by a query in datasource?
I suppose it's pretty straight forward...
In this particular case, I want to replace a view by a miodified version of the view code itself (my source is Snowflake although I suppose it does not matter)
EricMamet - Connect to the new data source as needed in a new query and navigate and transform it as necessary.
Then, open the advanced view of the new query and copy that code to the advance view of the old query.
Power BI will see that as the same query on the DAX side, not as a new table, which is I suspect what you want. You can then delete the new query you created.
If it is as simple as an identical query/view/table but a different server, you can just use the Change DataSource icon on the ribbon, but I suspect your issue is slightly more complex than that. That is great for switching servers and databases (dev/prod/test) but useless for switching tables, queries, views, etc.
If not, can you please be more specific about what you are trying to do. You can see the link below for some assistance on re-using M code from one query in another.
See this article if you need help using this M code in your model.
6 Replies
- amitchandakSuper User
EricMamet , giving a query in the advance option of connection?
- EricMametHelper I
Thanks amitchandak
I am already using a "View" but I want to replace it by a query with a modified version of the underlying SQL (without redefining an entirely new datasource if possible)
- edhansCommunity Champion
EricMamet - Connect to the new data source as needed in a new query and navigate and transform it as necessary.
Then, open the advanced view of the new query and copy that code to the advance view of the old query.
Power BI will see that as the same query on the DAX side, not as a new table, which is I suspect what you want. You can then delete the new query you created.
If it is as simple as an identical query/view/table but a different server, you can just use the Change DataSource icon on the ribbon, but I suspect your issue is slightly more complex than that. That is great for switching servers and databases (dev/prod/test) but useless for switching tables, queries, views, etc.
If not, can you please be more specific about what you are trying to do. You can see the link below for some assistance on re-using M code from one query in another.
See this article if you need help using this M code in your model.