cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
schwinnen Member
Member

Replace References - changing data sources

I am connected to a PostgreSQL database and have created several reports from a table contained within this database.  For simplicity, lets call that table_1.  To hopefully speed up my connections and refreshes, rather than connecting live to this table, someone is creating a materialized view for me to use.  This means I will have a new data source and a new table name.  What is the best way now to replace my data source while keeping all of my formulas?  In Tableau, you could just replace references for your fields, so if you right clicked on Field A, selected replace references and select Field B, anyplace in your entire workbook that used Field A would now be replaced with Field B.  I do not see a similar feature in Power BI, but I assume there has to be an easy way to change data sources without redoing all of my formulas. 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
nirvana_moksh Established Member
Established Member

Re: Replace References - changing data sources

@schwinnen - You can first create a new connection to this data source and once the preview is loaded in Power Query mode, click on Advanced Editor and copy the script for the establishment of the connection to the newly created view. Go to your existing query and click on the Advanced Editor for that query and replace the string that you see after 'Let source' for your table with this and make the necessary changes in the script like making sure the commas are in place, and that the proper reference names are listed after "#"

 

Edit - Also, as a best practice I always declare Parameters for Server Name, Database Name etc, which you can utilize too, so as to make these kinda changes a little more easier.

3 REPLIES 3
Highlighted
nirvana_moksh Established Member
Established Member

Re: Replace References - changing data sources

@schwinnen - You can first create a new connection to this data source and once the preview is loaded in Power Query mode, click on Advanced Editor and copy the script for the establishment of the connection to the newly created view. Go to your existing query and click on the Advanced Editor for that query and replace the string that you see after 'Let source' for your table with this and make the necessary changes in the script like making sure the commas are in place, and that the proper reference names are listed after "#"

 

Edit - Also, as a best practice I always declare Parameters for Server Name, Database Name etc, which you can utilize too, so as to make these kinda changes a little more easier.

schwinnen Member
Member

Re: Replace References - changing data sources

Thank you, @nirvana_moksh!  I appreciate the help.

akhilfaisal Frequent Visitor
Frequent Visitor

Re: Replace References - changing data sources

@nirvana_moksh That is a great way to change the entire data source. But is there a way for the actual 'replace reference' of fields like in tableau. Say I have a page with many views(or even an entire report).  The (e.g.) "Total Cost" on all of the different views are connected to a specific field. If I would feel another field actually makes more sense to go under "Total Cost", is there any way I can use a few clicks or edit a query to replace the reference of this "Total Cost" to another field(It has to simultaneously change for all the views in the report)? Just like the REPLACE REFERENCE in Tableau. Thanks in Advance.