Combine two excel tables with one-to-many relationship into pivot table

totalchaos

New Member
Joined
Jul 6, 2012
Messages
40
I have data tables into two separate worksheets as follows:

Sheet1 table: Unique values in column A
Excel 2007
AB
2Cost CodeBudget
3A10
4B20
5C30
6D40
Sheet1

<colgroup><col style="width: 48pt;" span="3" width="64"> <tbody>
</tbody>


Sheet 2 table: data with multiple cost codes

Excel 2007
ABC
2EmployeeCost CodeActual
31A3
41B5
52B8
62D10
Sheet2

<colgroup><col style="width: 48pt;" span="4" width="64"> <tbody>
</tbody>


The first table has a one-to-many relationship with the second table. That is, one cost code on table1 to multiple cost codes on table2. I want to combine the two tables into one pivot table with the results on a third sheet as such:

Excel 2007
ABC
1Cost CodeBudgetActual
2A103
3B2013
4C300
5D4010
Sheet3

<colgroup><col style="width: 48pt;" span="4" width="64"> <tbody>
</tbody>


Can anyone recommend a solution to this?
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Thanks for the link. The video explains consolidation which can only be done if each worksheet has the same structure. If I create a pivot table on table 2 only, I will get only cost codes with actual hours. I want to be able to combine the tables so that cost code C shows in the results even though there are no actual hours. I hope there is a work around if this is not possible.
 
Upvote 0
I think I got what you wanted using the consolidation.

In table one I took cost code & Budget then in table two I only took the cost code & Actual columns (don't take the employee column).
Excel Workbook
ABCD
2
3Sum of ValueColumn
4RowActualBudget
5A310
6B1320
7C30
8D1040
9
Sheet
 
Upvote 0
I tried the same thing and got the same result. Thanks. The next question is how can I do the same thing if the columns in the data table 2 are not aligned next to each other. Is there a way to select non-contiguous ranges in the reference box of the consolidation dialog window.
 
Upvote 0

Forum statistics

Threads
1,216,574
Messages
6,131,499
Members
449,653
Latest member
aurelius33

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