Updating data with Power Query when the updated data has an extra column and lookups are needed

tigerzen

Board Regular
Joined
Mar 8, 2023
Messages
209
Office Version
  1. 365
Platform
  1. Windows
I'm trying to use PQ to update a file which has a number of Pivot tables linked to the data. Basically it's the first table here which has a lookup to the second table. When the new data comes in, I then would like to replace the old data with it and have everything update accordingly, in this case the final update will only have Germany records.

PQ.xlsx
ABCDEFGHI
1CategoryNameGenderAge Dept
2IndiaTomMale36AdminRow LabelsCount of Name
3AustraliaFredMale45SalesAdmin2
4ItalyMaryFemale55HRFinance1
5IndiaSamMale23SalesHR3
6AustraliaJackMale55AdminSales2
7FranceBertMale61HRGrand Total8
8AustraliaDorisFemale28Finance
9ItalyNicolaFemale34HR
Data
Cell Formulas
RangeFormula
A2:A9A2=INDEX(Category!$C$2:$C$9,MATCH(Data!B2,Category!$B$2:$B$9,0))


PQ.xlsx
BC
1NameCountry
2TomIndia
3FredAustralia
4MaryItaly
5SamIndia
6JackAustralia
7BertFrance
8DorisAustralia
9NicolaItaly
10HarryGermany
11DanGermany
12FionaGermany
13NoelGermany
Category


Updated data
PQ_2.xlsx
ABCD
1NameGenderAge Dept
2HarryMale36Management
3DanMale55Management
4FionaFemale18Executive
5NoelMale60HR
Sheet1
 
If Table1 is already a query, then you just need to replace its source data (that you merge with your country table) with the new data set and refresh it.
Thanks again Rory, ok so I tried that and it works although I have to refresh twice, once for the merged query and again for the linked pivot tables. I had thought that I could just do one global refresh but can't see how to do that. Also, replacing the source data seems more manual than what I'd like. I again thought that PQ could automate some of these manual steps, but copying and pasting over the original data in PQ is only slightly more efficient than what I'm manually doing now. It does get a bit tedious when you have to run many reports often.
 
Upvote 0

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Where is the original source data? I generally prefer to keep that as a separate file that I just overwrite when I have new data (unless I need to keep a history).

I also prefer to build the pivot tables directly off the query rather than loading it to a table and then making the pivots off that, but since you're already set up that way, you should be able to just turn off background refresh for the query (uncheck the option below), then a RefreshAll should work:

1729848120769.png
 
Upvote 0
Where is the original source data? I generally prefer to keep that as a separate file that I just overwrite when I have new data (unless I need to keep a history).

I also prefer to build the pivot tables directly off the query rather than loading it to a table and then making the pivots off that, but since you're already set up that way, you should be able to just turn off background refresh for the query (uncheck the option below), then a RefreshAll should work:

View attachment 118526
Still not quite working. I've made the changes as per your post but it's not updating the Country field. I'll keep trying and your suggestion of building the pivot tables directly off the query is a good one.
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,874
Members
452,363
Latest member
merico17

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