Many to Many?

s1192

New Member
Joined
Apr 21, 2019
Messages
1
All

First time on the site so appologies if I can find the answer elsewhere.

I have a many to many situation, that I am looking to resolve to give me one dataset. Any advice on formula/ add ins that can be used (cant code in VBA) would be appreicated.

Eg Two data sets of

[TABLE="width: 192"]
<colgroup><col width="64" style="width:48pt" span="3"> </colgroup><tbody>[TR]
[TD="width: 64, bgcolor: transparent"]Contract[/TD]
[TD="width: 64, bgcolor: transparent"]Reinsurer[/TD]
[TD="width: 64, bgcolor: transparent"]Share[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]001X[/TD]
[TD="bgcolor: transparent"]Munich[/TD]
[TD="bgcolor: transparent, align: right"]0.3[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]001X[/TD]
[TD="bgcolor: transparent"]Swiss[/TD]
[TD="bgcolor: transparent, align: right"]0.6[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]001X[/TD]
[TD="bgcolor: transparent"]Lloyds[/TD]
[TD="bgcolor: transparent, align: right"]0.1[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]002X[/TD]
[TD="bgcolor: transparent"]LLoyds[/TD]
[TD="bgcolor: transparent, align: right"]0.2[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]002X[/TD]
[TD="bgcolor: transparent"]Muncih[/TD]
[TD="bgcolor: transparent, align: right"]0.3[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]002X[/TD]
[TD="bgcolor: transparent"]RSA[/TD]
[TD="bgcolor: transparent, align: right"]0.1[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]002X[/TD]
[TD="bgcolor: transparent"]Everest[/TD]
[TD="bgcolor: transparent, align: right"]0.1[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]002X[/TD]
[TD="bgcolor: transparent"]AIG[/TD]
[TD="bgcolor: transparent, align: right"]0.2[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]002X[/TD]
[TD="bgcolor: transparent"]AXA[/TD]
[TD="bgcolor: transparent, align: right"]0.1[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]003X[/TD]
[TD="bgcolor: transparent"]RSA[/TD]
[TD="bgcolor: transparent, align: right"]0.5[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]003X[/TD]
[TD="bgcolor: transparent"]AIG[/TD]
[TD="bgcolor: transparent, align: right"]0.4[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]003X[/TD]
[TD="bgcolor: transparent"]lloyds[/TD]
[TD="bgcolor: transparent, align: right"]0.1
[/TD]
[/TR]
</tbody>[/TABLE]


and


[TABLE="width: 192"]
<colgroup><col width="64" style="width:48pt" span="3"> </colgroup><tbody>[TR]
[TD="width: 64, bgcolor: transparent"]Contract[/TD]
[TD="width: 64, bgcolor: transparent"]Risk Code[/TD]
[TD="width: 64, bgcolor: transparent"]Amount[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]001X[/TD]
[TD="bgcolor: transparent"]A[/TD]
[TD="bgcolor: transparent, align: right"]1000[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]001X[/TD]
[TD="bgcolor: transparent"]B[/TD]
[TD="bgcolor: transparent, align: right"]2000[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]001X[/TD]
[TD="bgcolor: transparent"]C[/TD]
[TD="bgcolor: transparent, align: right"]2500[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]001X[/TD]
[TD="bgcolor: transparent"]D[/TD]
[TD="bgcolor: transparent, align: right"]3000[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]001X[/TD]
[TD="bgcolor: transparent"]E[/TD]
[TD="bgcolor: transparent, align: right"]4000[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]001X[/TD]
[TD="bgcolor: transparent"]F[/TD]
[TD="bgcolor: transparent, align: right"]1500[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]003X[/TD]
[TD="bgcolor: transparent"]G[/TD]
[TD="bgcolor: transparent, align: right"]10[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]003X[/TD]
[TD="bgcolor: transparent"]B[/TD]
[TD="bgcolor: transparent, align: right"]1500[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]003X[/TD]
[TD="bgcolor: transparent"]F[/TD]
[TD="bgcolor: transparent, align: right"]9000[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]003X[/TD]
[TD="bgcolor: transparent"]R[/TD]
[TD="bgcolor: transparent, align: right"]10000[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]003X[/TD]
[TD="bgcolor: transparent"]T[/TD]
[TD="bgcolor: transparent, align: right"]150000[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]002X[/TD]
[TD="bgcolor: transparent"]A[/TD]
[TD="bgcolor: transparent, align: right"]150[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]002X[/TD]
[TD="bgcolor: transparent"]B[/TD]
[TD="bgcolor: transparent, align: right"]1500[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]002X[/TD]
[TD="bgcolor: transparent"]C[/TD]
[TD="bgcolor: transparent, align: right"]150000[/TD]
[/TR]
</tbody>[/TABLE]

Would want to expand the second data set to include every reinsurer for every contract and their share (which I would multiply by the amount).

Thanks,
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Unless I misunderstand what you're after, this will work. You will need to be using Excel365 for new functions SORT and UNIQUE to work. Otherwise, you can populate row E18:L18 with a unique list of all the insurers.

Copy E18 across and down as far as necessary.

[FONT=Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif]
Book1
ABCDEFGHIJKL
3ContractReinsurerShare
4001XMunich0.3
5001XSwiss0.6
6001XLloyds0.1
7002XLLoyds0.2
8002XMuncih0.3
9002XRSA0.1
10002XEverest0.1
11002XAIG0.2
12002XAXA0.1
13003XRSA0.5
14003XAIG0.4
15003Xlloyds0.1
16
17
18ContractRisk CodeAmountAIGAXAEverestLloydsMuncihMunichRSASwiss
19001XA100000010003000600
20001XB2000000200060001200
21001XC2500000250075001500
22001XD3000000300090001800
23001XE40000004000120002400
24001XF150000015004500900
25003XG1040010050
26003XB150060000150007500
27003XF90003600009000045000
28003XR1000040000010000050000
29003XT15000060000001500000750000
30002XA15030151530450150
31002XB150030015015030045001500
32002XC15000030000150001500030000450000150000
Sheet30
Cell Formulas
RangeFormula
E18=TRANSPOSE(SORT(UNIQUE(B4:B15)))
E19=SUMPRODUCT(($A$4:$A$15=$A19)*($B$4:$B$15=E$18)*$C$4:$C$15)*$C19
[/FONT]
 
Upvote 0
Another Option will be to use Power Query and join the two tables on the Contract
Data Range
Data Range
[Table="class: grid"][tr][td] [/td][td]
A
[/td][td]
B
[/td][td]
C
[/td][td]
D
[/td][td]
E
[/td][td]
F
[/td][/tr]
[tr][td]
1
[/td][td]
Contract​
[/td][td]
Risk Code​
[/td][td]
Amount​
[/td][td]
Table1.Reinsurer​
[/td][td]
Table1.Share​
[/td][td]
Custom​
[/td][/tr]


[tr][td]
2
[/td][td]
001x​
[/td][td]
A​
[/td][td]
1000​
[/td][td]
Munich​
[/td][td]
0.3​
[/td][td]
300​
[/td][/tr]


[tr][td]
3
[/td][td]
001x​
[/td][td]
A​
[/td][td]
1000​
[/td][td]
Swiss​
[/td][td]
0.6​
[/td][td]
600​
[/td][/tr]


[tr][td]
4
[/td][td]
001x​
[/td][td]
A​
[/td][td]
1000​
[/td][td]
Lloyds​
[/td][td]
0.1​
[/td][td]
100​
[/td][/tr]


[tr][td]
5
[/td][td]
001x​
[/td][td]
B​
[/td][td]
2000​
[/td][td]
Munich​
[/td][td]
0.3​
[/td][td]
600​
[/td][/tr]


[tr][td]
6
[/td][td]
001x​
[/td][td]
B​
[/td][td]
2000​
[/td][td]
Swiss​
[/td][td]
0.6​
[/td][td]
1200​
[/td][/tr]


[tr][td]
7
[/td][td]
001x​
[/td][td]
B​
[/td][td]
2000​
[/td][td]
Lloyds​
[/td][td]
0.1​
[/td][td]
200​
[/td][/tr]


[tr][td]
8
[/td][td]
001x​
[/td][td]
C​
[/td][td]
2500​
[/td][td]
Munich​
[/td][td]
0.3​
[/td][td]
750​
[/td][/tr]


[tr][td]
9
[/td][td]
001x​
[/td][td]
C​
[/td][td]
2500​
[/td][td]
Swiss​
[/td][td]
0.6​
[/td][td]
1500​
[/td][/tr]


[tr][td]
10
[/td][td]
001x​
[/td][td]
C​
[/td][td]
2500​
[/td][td]
Lloyds​
[/td][td]
0.1​
[/td][td]
250​
[/td][/tr]


[tr][td]
11
[/td][td]
001x​
[/td][td]
D​
[/td][td]
3000​
[/td][td]
Munich​
[/td][td]
0.3​
[/td][td]
900​
[/td][/tr]


[tr][td]
12
[/td][td]
001x​
[/td][td]
D​
[/td][td]
3000​
[/td][td]
Swiss​
[/td][td]
0.6​
[/td][td]
1800​
[/td][/tr]


[tr][td]
13
[/td][td]
001x​
[/td][td]
D​
[/td][td]
3000​
[/td][td]
Lloyds​
[/td][td]
0.1​
[/td][td]
300​
[/td][/tr]


[tr][td]
14
[/td][td]
001x​
[/td][td]
E​
[/td][td]
4000​
[/td][td]
Munich​
[/td][td]
0.3​
[/td][td]
1200​
[/td][/tr]


[tr][td]
15
[/td][td]
001x​
[/td][td]
E​
[/td][td]
4000​
[/td][td]
Swiss​
[/td][td]
0.6​
[/td][td]
2400​
[/td][/tr]


[tr][td]
16
[/td][td]
001x​
[/td][td]
E​
[/td][td]
4000​
[/td][td]
Lloyds​
[/td][td]
0.1​
[/td][td]
400​
[/td][/tr]


[tr][td]
17
[/td][td]
001x​
[/td][td]
F​
[/td][td]
1500​
[/td][td]
Munich​
[/td][td]
0.3​
[/td][td]
450​
[/td][/tr]


[tr][td]
18
[/td][td]
001x​
[/td][td]
F​
[/td][td]
1500​
[/td][td]
Swiss​
[/td][td]
0.6​
[/td][td]
900​
[/td][/tr]


[tr][td]
19
[/td][td]
001x​
[/td][td]
F​
[/td][td]
1500​
[/td][td]
Lloyds​
[/td][td]
0.1​
[/td][td]
150​
[/td][/tr]


[tr][td]
20
[/td][td]
002x​
[/td][td]
A​
[/td][td]
150​
[/td][td]
Lloyds​
[/td][td]
0.2​
[/td][td]
30​
[/td][/tr]


[tr][td]
21
[/td][td]
002x​
[/td][td]
A​
[/td][td]
150​
[/td][td]
Munich​
[/td][td]
0.3​
[/td][td]
45​
[/td][/tr]


[tr][td]
22
[/td][td]
002x​
[/td][td]
A​
[/td][td]
150​
[/td][td]
RSA​
[/td][td]
0.1​
[/td][td]
15​
[/td][/tr]


[tr][td]
23
[/td][td]
002x​
[/td][td]
A​
[/td][td]
150​
[/td][td]
Everest​
[/td][td]
0.1​
[/td][td]
15​
[/td][/tr]


[tr][td]
24
[/td][td]
002x​
[/td][td]
A​
[/td][td]
150​
[/td][td]
AIG​
[/td][td]
0.2​
[/td][td]
30​
[/td][/tr]


[tr][td]
25
[/td][td]
002x​
[/td][td]
A​
[/td][td]
150​
[/td][td]
AXA​
[/td][td]
0.1​
[/td][td]
15​
[/td][/tr]


[tr][td]
26
[/td][td]
002x​
[/td][td]
B​
[/td][td]
1500​
[/td][td]
Lloyds​
[/td][td]
0.2​
[/td][td]
300​
[/td][/tr]


[tr][td]
27
[/td][td]
002x​
[/td][td]
B​
[/td][td]
1500​
[/td][td]
Munich​
[/td][td]
0.3​
[/td][td]
450​
[/td][/tr]


[tr][td]
28
[/td][td]
002x​
[/td][td]
B​
[/td][td]
1500​
[/td][td]
RSA​
[/td][td]
0.1​
[/td][td]
150​
[/td][/tr]


[tr][td]
29
[/td][td]
002x​
[/td][td]
B​
[/td][td]
1500​
[/td][td]
Everest​
[/td][td]
0.1​
[/td][td]
150​
[/td][/tr]


[tr][td]
30
[/td][td]
002x​
[/td][td]
B​
[/td][td]
1500​
[/td][td]
AIG​
[/td][td]
0.2​
[/td][td]
300​
[/td][/tr]


[tr][td]
31
[/td][td]
002x​
[/td][td]
B​
[/td][td]
1500​
[/td][td]
AXA​
[/td][td]
0.1​
[/td][td]
150​
[/td][/tr]


[tr][td]
32
[/td][td]
003x​
[/td][td]
G​
[/td][td]
10​
[/td][td]
RSA​
[/td][td]
0.5​
[/td][td]
5​
[/td][/tr]


[tr][td]
33
[/td][td]
003x​
[/td][td]
G​
[/td][td]
10​
[/td][td]
AIG​
[/td][td]
0.4​
[/td][td]
4​
[/td][/tr]


[tr][td]
34
[/td][td]
003x​
[/td][td]
G​
[/td][td]
10​
[/td][td]
Lloyds​
[/td][td]
0.1​
[/td][td]
1​
[/td][/tr]


[tr][td]
35
[/td][td]
003x​
[/td][td]
B​
[/td][td]
1500​
[/td][td]
RSA​
[/td][td]
0.5​
[/td][td]
750​
[/td][/tr]


[tr][td]
36
[/td][td]
003x​
[/td][td]
B​
[/td][td]
1500​
[/td][td]
AIG​
[/td][td]
0.4​
[/td][td]
600​
[/td][/tr]


[tr][td]
37
[/td][td]
003x​
[/td][td]
B​
[/td][td]
1500​
[/td][td]
Lloyds​
[/td][td]
0.1​
[/td][td]
150​
[/td][/tr]


[tr][td]
38
[/td][td]
003x​
[/td][td]
F​
[/td][td]
9000​
[/td][td]
RSA​
[/td][td]
0.5​
[/td][td]
4500​
[/td][/tr]


[tr][td]
39
[/td][td]
003x​
[/td][td]
F​
[/td][td]
9000​
[/td][td]
AIG​
[/td][td]
0.4​
[/td][td]
3600​
[/td][/tr]


[tr][td]
40
[/td][td]
003x​
[/td][td]
F​
[/td][td]
9000​
[/td][td]
Lloyds​
[/td][td]
0.1​
[/td][td]
900​
[/td][/tr]


[tr][td]
41
[/td][td]
003x​
[/td][td]
R​
[/td][td]
10000​
[/td][td]
RSA​
[/td][td]
0.5​
[/td][td]
5000​
[/td][/tr]


[tr][td]
42
[/td][td]
003x​
[/td][td]
R​
[/td][td]
10000​
[/td][td]
AIG​
[/td][td]
0.4​
[/td][td]
4000​
[/td][/tr]


[tr][td]
43
[/td][td]
003x​
[/td][td]
R​
[/td][td]
10000​
[/td][td]
Lloyds​
[/td][td]
0.1​
[/td][td]
1000​
[/td][/tr]


[tr][td]
44
[/td][td]
003x​
[/td][td]
T​
[/td][td]
150000​
[/td][td]
RSA​
[/td][td]
0.5​
[/td][td]
75000​
[/td][/tr]


[tr][td]
45
[/td][td]
003x​
[/td][td]
T​
[/td][td]
150000​
[/td][td]
AIG​
[/td][td]
0.4​
[/td][td]
60000​
[/td][/tr]


[tr][td]
46
[/td][td]
003x​
[/td][td]
T​
[/td][td]
150000​
[/td][td]
Lloyds​
[/td][td]
0.1​
[/td][td]
15000​
[/td][/tr]


[tr][td]
47
[/td][td]
002x​
[/td][td]
C​
[/td][td]
150000​
[/td][td]
Lloyds​
[/td][td]
0.2​
[/td][td]
30000​
[/td][/tr]


[tr][td]
48
[/td][td]
002x​
[/td][td]
C​
[/td][td]
150000​
[/td][td]
Munich​
[/td][td]
0.3​
[/td][td]
45000​
[/td][/tr]


[tr][td]
49
[/td][td]
002x​
[/td][td]
C​
[/td][td]
150000​
[/td][td]
RSA​
[/td][td]
0.1​
[/td][td]
15000​
[/td][/tr]


[tr][td]
50
[/td][td]
002x​
[/td][td]
C​
[/td][td]
150000​
[/td][td]
Everest​
[/td][td]
0.1​
[/td][td]
15000​
[/td][/tr]


[tr][td]
51
[/td][td]
002x​
[/td][td]
C​
[/td][td]
150000​
[/td][td]
AIG​
[/td][td]
0.2​
[/td][td]
30000​
[/td][/tr]


[tr][td]
52
[/td][td]
002x​
[/td][td]
C​
[/td][td]
150000​
[/td][td]
AXA​
[/td][td]
0.1​
[/td][td]
15000​
[/td][/tr]


[tr][td]
53
[/td][td]
[/td][td]
[/td][td]
[/td][td]
[/td][td]
[/td][td]
[/td][/tr]
[/table]

Here is the Mcode

Code:
let
let
    Source = Table.NestedJoin(Table2,{"Contract"},Table1,{"Contract"},"Table1",JoinKind.LeftOuter),
    #"Expanded Table1" = Table.ExpandTableColumn(Source, "Table1", {"Reinsurer", "Share"}, {"Table1.Reinsurer", "Table1.Share"}),
    #"Added Custom" = Table.AddColumn(#"Expanded Table1", "Custom", each [Amount]*[Table1.Share])
in
    #"Added Custom"
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,178
Members
453,021
Latest member
Justyna P

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