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
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
I'm not sure I follow but it sounds like you just need to load the second table as a query, merge it with the first and then filter for Germany.
 
Upvote 0
I'm not sure I follow but it sounds like you just need to load the second table as a query, merge it with the first and then filter for Germany.
Hi Rory, I may not have explained it properly but each time I run the report I need PQ to update everything, I made all 4 records Germany in the new file so I could see the change easily. In the actual file the records will be similar so I wouldn't be able to just filter as I wouldn't know what to filter by.
 
Upvote 0
I'm afraid I don't really know whet you mean then. Which data changes and what is supposed to happen?
 
Upvote 0
I'm afraid I don't really know whet you mean then. Which data changes and what is supposed to happen?
The desired output should look like:

PQ.xlsx
ABCDE
1NameGenderAge DeptCategory
2HarryMale36ManagementGermany
3DanMale55ManagementGermany
4FionaFemale18ExecutiveGermany
5NoelMale60HRGermany
Data
Cell Formulas
RangeFormula
E2:E5E2=INDEX('Input 2'!$C$2:$C$13,MATCH(Data!A2,'Input 2'!$B$2:$B$13,0))


But the data comes to me without the index match part as per the third table in post 1
 
Upvote 0
Then you just need my original answer without the filtering part, as far as I can tell. You'd merge the two queries using the Name column as the link, and then expand the resulting table column to just return the country.
 
Upvote 0
Then you just need my original answer without the filtering part, as far as I can tell. You'd merge the two queries using the Name column as the link, and then expand the resulting table column to just return the country.
Hi Rory, thanks for your assistance. I realise the highlighting may have been confusing. The output should be as per post 5 ie with Name, Gender etc.
I've been able to get the merged query to work for the initial issue which combines the first 2 tables as per post 1. I cannot see how I can now update the information when Table 3 from Post 1 comes in. Table 3 information replaces Table 1 but I need it to still link with Table 2, I hope that's a bit clearer.
 
Upvote 0
You need Table1 to be a query from somewhere, then update the source of that query with the new data.
 
Upvote 0
You need Table1 to be a query from somewhere, then update the source of that query with the new data.
Not sure I follow that. Table 1 is already a query as it's used to create the connection between it and the Country table (2nd table in post 1). When you say from somewhere is there an extra step I need to perform?
 
Upvote 0
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.
 
Upvote 0

Forum statistics

Threads
1,224,884
Messages
6,181,568
Members
453,053
Latest member
Kiranm13

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