combining two slightly different datasets

bertusavius

Board Regular
Joined
Feb 28, 2008
Messages
82
I have two tables

TableA
name</SPAN>
date</SPAN>
property2</SPAN>
key</SPAN>
eventa</SPAN>
1-1-2012</SPAN>
xxx</SPAN>
1-1-2012xxx</SPAN>
eventb</SPAN>
2-5-2012</SPAN>
yyy</SPAN>
2-5-2012yyy</SPAN>
eventc</SPAN>
2-5-2012</SPAN>
yyy</SPAN>
2-5-2012yyy</SPAN>

<TBODY>
</TBODY>


of which I generate this pivot table:

1-1-2012
xxx
1
yyy
2-5-2012
xxx
yyy
2

<TBODY>
</TBODY>



also tableB
name
date
property2
value
key(unique)
action1
1-1-2012
xxx
99
1-1-2012xxx
action2
2-5-2012
yyy
55
2-5-2012yyy

<TBODY>
</TBODY>


Now I'd like to combine the two by creating a relationship between the two key columns above.

What I'd like to see is this:

1-1-2012
xxx
1
99
yyy
2-5-2012
xxx
yyy
2
55

<TBODY>
</TBODY>


but what I get is this:

1-1-2012
xxx
1
99
yyy
99
2-5-2012
xxx
99
yyy
2
99

<TBODY>
</TBODY>


How could I relate those two values correctly?
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
As I see it, you used :
tableB[date]
tableA[property2]
countrows measure on tableA
A measure based on tableB[value]

Using property2 from tableB (your dimension) should solve the issue.

Explanation: for given measures, PowerPivot will show all combinations of attributes for which facts exist for at leat one measure.

In your case, this translates to:
Show all combinations of tableB[date] and tableA[property] for which there exists some tableB[value].

Of course for every value in tableB[date] there exists some tableB[value] independantly of what the value of tableA[property2] is.

When you have a dimension table, it is best to hide the redundant key columns from the fact table, to avoid this type of confusions.
 
Upvote 0
I understand your point.

However the problem is that in neither of the tables, the property2 value is unique; thats exactly the reason I created a calculated column of keys.
I should have made that clearer in the example.


As you might remember: the property2 represents the bucket field of my previous problem.
Table B represents this shift information in with wich a aggregate totals per time-bucket.

Table A represents a database of revenue of which time-bucket information is a property. This is a separate model.

I'd like to combine the two models to align the cost of personel per time-bucket with the revenue in the same time-bucket.
 
Upvote 0
Say you have the following structure, with the appropriate - and hopefully obvious - relationships :
Dates {date}
Buckets {bucket}
Costs {date, bucket, cost}
Revenue {date, bucket, revenue}

Now you could simply have a pivot table with:
Dates[date] , Buckets[bucket] on rows
SUM(Costs[revenue]), SUM(Revenue[revenue]) in values.

In other words, you should add a Date table to your model, if you do not have one already. Link TableA and TableB to the Tijd and Date dimensions. Link all other tables to your Date dimension as required. Hide the keys in the data tables.
 
Upvote 0
Adding a date table was indeed the solution.

With your help I think I'll be able to make the model complete.

Many thanks indeed.
 
Upvote 0

Forum statistics

Threads
1,214,422
Messages
6,119,395
Members
448,891
Latest member
tpierce

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