M2M Relationship tricky situation

Lasselakan

New Member
Joined
Feb 3, 2014
Messages
3
I have a problem that I've not seen any example of how to solve regarding PowerPivot and Pivot Tables. I have 3 tables; stores, visitors and store_competitors.

'stores' looks like this:
store_id, store_name

'visitors' looks like this:
visitor_id, visited_store_id

'store_competitors' looks like this:
store_id, competing_store_id

Now I want to be able to pick a 'stores'.store_name (e.g. in a slicer) and then illustrate how many visitors each of that store's competitors has had. The problem is that I cannot add Relationship between 'visitors' and 'store_competitors' on visited_store_id = competing_store_id since both columns can contain duplicates (a store can have many visitors and many competitors). I can however create a Relationship from each of these to 'stores'.store_id but that doesn't give proper result, it acts as if the Relationship doesn't "reach" all the way from 'visitors' to 'store_competitors' (i.e. if I slice on a specific 'store_competitors'.store_id then COUNT('visitors'.visitor_id) is not properly limited to the competitors of that store, but instead shows all stores in the whole table and shows counts as 0 for everyone and Excel also suggests that a relationship might be needed. I guess it's asking about a relationship between 'visitors' and 'store_competitors' but how can I add that if both columns have duplicates?)

Here is a more specific example with example data:

'stores'
10 storeX
11 storeY

'visitors'
20 15
21 15
22 16

'store_competitors'
10 15
11 15
11 16

If I pick storeY in the slicer I want to see the result as competing_store_id(15) had 2 visitors and competing_store_id(16) had 1 visitor.

Please give me a hand on this one. I'm familiar with SQL but find PowerPivot a bit tricky in some aspects like this one...
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.

Forum statistics

Threads
1,216,179
Messages
6,129,336
Members
449,503
Latest member
glennfandango

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