How can I change the source query for a table.

JeffGrant

Well-known Member
Joined
Apr 7, 2021
Messages
558
Office Version
  1. 365
Platform
  1. Windows
Hi All,

A simple question, but I am sure that the answer is not so simple.

I have a table, Table 1, that is based on Query 1, that uses a csv file as the input data into PQ.

I now have the same table, Table 2, using Query 2 that uses Json data as the input into PQ.

Because of the amount of formulas that have built up over time in Table 1, I cannot simply delete Table 1, and load Query 2 to the location of the Table 1. I will end up with a lot of #ref errors......

How can I change the source query for Table 1 from Query 1 to Query 2 so that all the dependant formulas remain intact.

I hope there is a simple answer to this one.

As always, all guidance is much appreciated.
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
UPDATE...

I have copied all of the code from Query 2 into Query 1 and commented out the Original code

Now I am getting this error.

1687761497948.png


I don't understand why I am getting this error, because all of the table column headers are the same, spelling and capitalisation, and the the same number of columns exists in both tables.

Next to check is data types and make sure they are the same.

thanks in advance
 
Upvote 0
I would have thought that all you needed to change was the initial Source statement in your M code.
 
Upvote 0
Hi Rory, thanks for that. Maybe I was not very clear.

The issue is not the Source of the query, the Source for the query comes from various API calls.

The issue is changing the query name for the resultant table in the worksheet.

cheers
 
Upvote 0
UPDATE....

Thought I would try a different approach.

Rather than keep the table the same and change the source query, I have done a Find & Replace and changed the name of the table where all of the formulas point.

So now the formulas point to the table that is created by the Json data.

Let's see what tomorrow bring, when all the scripts run...Here's hoping all will be fine.
 
Upvote 0
Solved...

I deleted some columns near the table.
Ran the PQ code.
Add the columns back in

=> no more messages. working like a dream :-)
 
Upvote 0
Solution

Forum statistics

Threads
1,223,911
Messages
6,175,324
Members
452,635
Latest member
laura12345

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top