Power Query - Merging Tables only shows first table data

jaspalsd

Board Regular
Joined
Feb 3, 2014
Messages
72
Hi,

I have searched online tutorials and I am stumped as to why I can't merge two tables in Power query.

I have therefore created a very simple example

ANIMALCOUNTID
DOG
1​
2​
CAT
5​
1​



ANIMALCOUNTID
CAT
6​
1​
MONKEY
3​
4​


If I do the the follow I will get these results:
Get Data > Combine queries > Merge > Table 1 (Select ID) and Table 2 (Select ID) > Full Outer Join


=Table.NestedJoin(Table1, {"ID"}, Table2, {"ID"}, "Table2", JoinKind.FullOuter)


ANIMALCOUNTIDTable2
CAT51

nullnullnull

DOG12



Can anyone please advise why joining on the Unique Identifier and performing a full outer join is returning the results above.


Thanks,

Jas
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
When I do a full outer join as you describe and expand the table, here are the results.

ANIMALCOUNTIDANIMALCountIDANIMALCOUNTIDANIMAL.1Count.1ID.1
DOG12CAT61CAT51CAT61
CAT51MONKEY34MONKEY34
DOG12


The Mcode for the full outer join are as follows

Power Query:
let
    Source = Table.NestedJoin(Table1, {"ID"}, Table2, {"ID"}, "Table2", JoinKind.FullOuter),
    #"Expanded Table2" = Table.ExpandTableColumn(Source, "Table2", {"ANIMAL", "Count", "ID"}, {"ANIMAL.1", "Count.1", "ID.1"})
in
    #"Expanded Table2"

You need to expand the table by double clicking on the double arrows in the upper right corner.
 
Upvote 0
Hi,

Thanks for the response. I might be a dummy here, but I am hoping to see the end result where the count is summarized as a total.

I could append but then again, it'll be on different rows e.g.

IDANIMALCOUNT
2​
DOG
1​
1​
CAT
5​
1​
CAT
6​
4​
MONKEY
3​


However, I do not wish to pivot because my pivot has multiple months and I wish to avoid having to select all months manually. I will say there are 150 approx months, hence why I wish to avoid that.

Thank you
 
Upvote 0
It sounds like you want to append and then group.
 
Upvote 0
It sounds like you want to append and then group.
so to give further clarity, I was provided with 2 extracts but in different month ranges so I had to insert months with no data and have these with a sum of 0

Extract 1: Mar20 to Oct21
Extract 2: Nov21 to Jan23

For below, lets say Extract 1: Mar-20
Extract 2: Apr-20

So I added in the missing months in both extracts so that the columns were consistent

I then appended. If I pivot then the months will need to be added in manually and also they show in alphabetical order and it'll then have a heading SUM Apr-20.


On your point of grouping, I can see that option, so I can group by Agreement and Schedule (an agreement may have more than 1 schedule) but my concern is what I want to sum is 154 months...



AgreementScheduleProduct CodeCustomerIntroducerCHANNELAsset Type DescriptionAsset DescriptionStart DateEnd DateVariable DealMar-20Apr-20
ABC111dummydummydummydummydummy
06-Sep-18​
06-Sep-21​
dummy
50​
0.00​

AgreementScheduleProduct CodeCustomerIntroducerCHANNELAsset Type DescriptionAsset DescriptionStart DateEnd DateVariable DealMar-20Apr-20
ABC11dummydummydummydummydummydummy
06-Sep-18​
06-Sep-21​
dummy
0.00​
50.00​
 
Upvote 0
You should unpivot the extracts so that the months are in rows, not separate columns, then append and then pivot as the last step. Then you wouldn't need to add missing months or add up 154 columns.
 
Upvote 0
You should unpivot the extracts so that the months are in rows, not separate columns, then append and then pivot as the last step. Then you wouldn't need to add missing months or add up 154 columns.
hi, it was how the reports were given to me and I can see why because there is a potential for the CSVs to go over the 1m row limit (agreement, account types, each month for almost 15 years) ...I think I'll just append the data in table format and then perform sumifs on another worksheet
 
Upvote 0
I meant unpivot them in PQ. The unpivoted data doesn't need to be loaded to a worksheet.
 
Upvote 0
sorry if I am confusing you.

The extracts were from SQL Developer and then extracted to CSV format and never pivoted.

If you mean there is a way to change the format where the months are in the columns but I am able to put these into the rows along with the values then are you able to advise.

Thanks
 
Upvote 0
I think we've gone so far away from the example data that you posted, that I'm not really sure what your source data actually looks like, or what your end goal is?
 
Upvote 0

Forum statistics

Threads
1,215,025
Messages
6,122,731
Members
449,093
Latest member
Mnur

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