SOLVED

Replace Data Connection with a PowerQuery

%3CLINGO-SUB%20id%3D%22lingo-sub-180047%22%20slang%3D%22en-US%22%3EReplace%20Data%20Connection%20with%20a%20PowerQuery%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-180047%22%20slang%3D%22en-US%22%3E%3CP%3EHi%2C%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EI%20have%20searched%20far%20and%20wide%20for%20this.%20I%20have%20a%20lot%20of%20workbooks%20that%20use%20Data%20Connections.%20I%20would%20like%20to%20replace%20them%20with%20PowerQueries%20as%20they%20are%20a%20bit%20more%20flexible%20and%20easier%20to%20maintain%20whenever%20data%20source%20changes.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EI%20managed%20to%20find%20a%20way%20to%20do%20that%20without%20breaking%20formula%20references%20etc.%20But%20now%20I'm%20left%20with%20both%20a%20PowerQuery%20(as%20%22Connection%20Only%22)%20and%20a%20Data%20Connection%20that%20loads%20data%20from%20PowerQuery%20(example%20attached%2C%20you%20need%20to%20go%20to%20Data-%26gt%3BExisting%20Connections%20to%20see%20%22Scorecard%20NPS%22%20connection%20as%20for%20some%20reason%20it%20disappears%20from%20Connection%20list%20on%20the%20side%20panel).%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIs%20there%20a%20better%20way%20to%20do%20it%3F%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ERegards%2C%20Jarek%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-180047%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-181572%22%20slang%3D%22en-US%22%3ERe%3A%20Replace%20Data%20Connection%20with%20a%20PowerQuery%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-181572%22%20slang%3D%22en-US%22%3EYou%E2%80%99re%20welcome%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-181555%22%20slang%3D%22en-US%22%3ERe%3A%20Replace%20Data%20Connection%20with%20a%20PowerQuery%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-181555%22%20slang%3D%22en-US%22%3E%3CP%3EThat's%20actually%20quite%20smart%20and%20easy%20fix.%3C%2FP%3E%3CP%3EUnless%20you%20have%20Pivot%20Tables%20or%20Graphs%20connecting%20to%20that%20table%20it%20will%20work.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-181448%22%20slang%3D%22en-US%22%3ERe%3A%20Replace%20Data%20Connection%20with%20a%20PowerQuery%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-181448%22%20slang%3D%22en-US%22%3EHi%3CBR%20%2F%3E%3CBR%20%2F%3EWhat%20I%20would%20try%20is%20this%3A%3CBR%20%2F%3E%3CBR%20%2F%3ELoad%20your%20data%20into%20a%20table%20with%20Power%20Query%20and%20name%20it%20Table1PQ%20(ensure%20it%20has%20exactly%20the%20same%20column%20names%20as%20your%20current%20Table1)%3CBR%20%2F%3E%3CBR%20%2F%3EDo%20a%20find%20%2F%20replace%20on%20your%20entire%20workbook%20for%20%3D%20and%20replace%20with%20%5E%3D%3CBR%20%2F%3EThat%20should%20convert%20your%20fomulas%20to%20text%3CBR%20%2F%3E%3CBR%20%2F%3EDelete%20your%20original%20Table1%20and%20the%20connection%3CBR%20%2F%3E%3CBR%20%2F%3ERename%20your%20Table1PQ%20to%20Table1%3CBR%20%2F%3E%3CBR%20%2F%3EDo%20another%20find%20and%20replace%20%5E%3D%20to%20%3D%3CBR%20%2F%3E%3CBR%20%2F%3EAll%20your%20formula%20should%20work%20again.%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-181138%22%20slang%3D%22en-US%22%3ERe%3A%20Replace%20Data%20Connection%20with%20a%20PowerQuery%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-181138%22%20slang%3D%22en-US%22%3E%3CP%3EHi%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20spreadsheet%20is%20just%20example.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ELong%20story%20short%3A%3C%2FP%3E%3CP%3EI%20am%20looking%20for%20a%20good%20way%20to%20replace%20data%20connection%20with%20a%20PowerQuery.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHere's%20a%20long%20story%3A%3C%2FP%3E%3CP%3E%22Scorecard%20NPS%22%20used%20to%20load%20data%20to%20a%20table%20called%20%22Table1%22.%3C%2FP%3E%3CP%3EThere%20are%20a%20lot%20of%20measures%20(formulas%2C%20charts%20etc)%20that%20were%20using%20Table1%20as%20a%20data%20source.%3C%2FP%3E%3CP%3E%22Scorecard%20NPS%22%20data%20connection%20takes%20a%20long%20time%20to%20refresh%20as%20it%20is%20using%20Access%20Database%20from%20virtual%20drive%20(over%20the%20network).%20Since%20this%20data%20is%20also%20available%20in%20SQL%20Server%2C%20I%26nbsp%3Bwrote%20a%20query%20and%20want%20to%20make%20the%20%22Scorecard%20NPS%22%20feed%20data%20from%20SQL%20Server%2C%20not%20Access%20(which%20now%20takes%2010%20second%2C%20not%2015%20minutes).%3C%2FP%3E%3CP%3EI%20also%20want%20to%20replace%20data%20connection%20with%20PowerQuery%20as%20it's%20easier%20to%20edit%20the%20query%20this%20way.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20tried%20different%20ways%20to%20replace%20data%20connection%20with%20PowerQuery%20but%20they%20either%20resulted%20in%20%22REF%22%20errors%20or%20converting%20formulas%20like%20%22sum(Table1%5BNPScore%5D)%22%20to%20%22sum(A1%3AA10)%22.%3C%2FP%3E%3CP%3EThe%20spreadsheet%20I%20attached%20was%20my%20best%20attempt%20to%20replace%20it%20without%20those%20issues%2C%20but%20now%20I%20ended%20up%20with%201%20connection%20and%201%20PowerQuery%20for%20some%20reason.%20Ideally%20I%20would%20like%20to%20remove%20the%20connection%20and%20only%20leave%20PowerQuery%20but%20I%20cannot%20seem%20to%20do%20that.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-181128%22%20slang%3D%22en-US%22%3ERe%3A%20Replace%20Data%20Connection%20with%20a%20PowerQuery%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-181128%22%20slang%3D%22en-US%22%3EHi%20Jaroslaw%2C%3CBR%20%2F%3E%3CBR%20%2F%3ESo%20in%20your%20file%20do%20you%20just%20have%20Pivot%20Tables%20feeding%20off%20Scorecard%20NPS%2C%20or%20other%20things%20as%20well%3F%3CBR%20%2F%3EWhat%20type%20of%20formula%20was%20breaking%3F%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E
New Contributor

Hi,

 

I have searched far and wide for this. I have a lot of workbooks that use Data Connections. I would like to replace them with PowerQueries as they are a bit more flexible and easier to maintain whenever data source changes.

 

I managed to find a way to do that without breaking formula references etc. But now I'm left with both a PowerQuery (as "Connection Only") and a Data Connection that loads data from PowerQuery (example attached, you need to go to Data->Existing Connections to see "Scorecard NPS" connection as for some reason it disappears from Connection list on the side panel).

 

Is there a better way to do it?

 

Regards, Jarek

6 Replies
Hi Jaroslaw,

So in your file do you just have Pivot Tables feeding off Scorecard NPS, or other things as well?
What type of formula was breaking?


Hi,

 

The spreadsheet is just example.

 

Long story short:

I am looking for a good way to replace data connection with a PowerQuery.

 

Here's a long story:

"Scorecard NPS" used to load data to a table called "Table1".

There are a lot of measures (formulas, charts etc) that were using Table1 as a data source.

"Scorecard NPS" data connection takes a long time to refresh as it is using Access Database from virtual drive (over the network). Since this data is also available in SQL Server, I wrote a query and want to make the "Scorecard NPS" feed data from SQL Server, not Access (which now takes 10 second, not 15 minutes).

I also want to replace data connection with PowerQuery as it's easier to edit the query this way.

 

I tried different ways to replace data connection with PowerQuery but they either resulted in "REF" errors or converting formulas like "sum(Table1[NPScore])" to "sum(A1:A10)".

The spreadsheet I attached was my best attempt to replace it without those issues, but now I ended up with 1 connection and 1 PowerQuery for some reason. Ideally I would like to remove the connection and only leave PowerQuery but I cannot seem to do that.

best response confirmed by Jaroslaw Szczygielski (New Contributor)
Solution
Hi

What I would try is this:

Load your data into a table with Power Query and name it Table1PQ (ensure it has exactly the same column names as your current Table1)

Do a find / replace on your entire workbook for = and replace with ^=
That should convert your fomulas to text

Delete your original Table1 and the connection

Rename your Table1PQ to Table1

Do another find and replace ^= to =

All your formula should work again.

That's actually quite smart and easy fix.

Unless you have Pivot Tables or Graphs connecting to that table it will work.

 

Thanks

You’re welcome
When I Do another find and replace ^= to =, I get a formula error pop up