Combining results of 2 pivot tables into 1

saltyorange

New Member
Joined
Jul 23, 2012
Messages
1
I have data with 2 key fields, an origin location and destination location and then a cost. I have one pivot table that has the sum of the cost by origin. I have another one that has a sum by destination. I want to get a table that has the location and then the Cost associated with when the location is an origin and then the cost associated with the location as a destination.

A simplified example is below. I have more fields than just cost, but wanted to keep it simple. Any thoughts on how to do this? (aside from just doing it in Access where it would be very easy).

Data
A B 500
A C 400
A D 300
B A 550
B C 700
etc

Pivot Table 1
A 800
B 1250

Pivot Table 2
A 550
B 500
C 1100
D 300

Final Result desired
Location Cost from Origin Cost from Destination
A 800 550
B 1250 500
C 1100
D 300
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Hi

I don't understand the example, sorry.

However, if you have an Access query that gives the result, just use the same SQL in Excel. Such as a query table (or pivot table or even via VBA a recordset). Excel help on external data queries refers.

HTH
 
Upvote 0
Hi saltyorange

you can do this by creating two DAX measures:


CostFromOrigin:=IF(HASONEVALUE(Table1[Destination]),SUMX(FILTER(ALL(Table1),Table1[Origin]=VALUES(Table1[Destination])), Table1[Cost]))

CostFromDestination:=IF(HASONEVALUE(Table1[Destination]),SUMX(FILTER(ALL(Table1),Table1[Destination]=VALUES(Table1[Destination])), Table1[Cost]))

Here I assume you placed the [destination] column on pivot table rows (2nd one in your sample table), as it has a comprehensive list of locations.


Javier Guillen
Senior Consultant, Mariner
Email:
javier.guillen@mariner-usa.com
PowerPivot Blog: http://javierguillen.wordpress.com
Twitter: @javiguillen
 
Upvote 0

Forum statistics

Threads
1,213,533
Messages
6,114,179
Members
448,554
Latest member
Gleisner2

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