cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
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
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.

View solution in original post

3 REPLIES 3
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.

View solution in original post

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.

Helpful resources

Announcements
Can You Solve These Challenge

Challenge: Can You Solve These?

Find out how to participate in the first Power BI 'Can You Solve These?' challenge.

Community News & Announcements

Community News & Announcements

Get your latest community news and announcements.

Virtual Launch Event

Microsoft Business Applications October Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

Community Kudopalooza

Win Power BI Swag with Community Kudopalooza!

Each week, complete activities and be qualified in the drawing for cool Power BI Swag.

Users Online
Currently online: 44 members 953 guests
Please welcome our newest community members: