Hi there,
I want to know if there's a way to brake-down to components a data table according to weight?
I have a portfolio of equities and etf's (table 1) , and I want that every ETF in it will be 'opened' according to the weights (table 3) of its related index (table 2) , so I'll get a table like in the 'Desired Query'.
Is that doable?
Thanks in advance
Table 1
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]Portfolio components[/TD]
[TD]Balance[/TD]
[/TR]
[TR]
[TD]SPDR[/TD]
[TD]10,000[/TD]
[/TR]
[TR]
[TD]AAPL[/TD]
[TD]5,000[/TD]
[/TR]
[TR]
[TD]MSFT[/TD]
[TD]4,000[/TD]
[/TR]
[TR]
[TD]QQQ[/TD]
[TD]3,000[/TD]
[/TR]
</tbody>[/TABLE]
Table 2
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]Portfolio components[/TD]
[TD]Linked Index[/TD]
[/TR]
[TR]
[TD]SPDR[/TD]
[TD]S&P500[/TD]
[/TR]
[TR]
[TD]QQQ[/TD]
[TD]Nasdaq100[/TD]
[/TR]
</tbody>[/TABLE]
Table 4
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]Index[/TD]
[TD]Sector[/TD]
[TD]Weight[/TD]
[/TR]
[TR]
[TD]S&P500[/TD]
[TD]Technology[/TD]
[TD]20%[/TD]
[/TR]
[TR]
[TD]S&P500[/TD]
[TD]Energy[/TD]
[TD]40%[/TD]
[/TR]
[TR]
[TD]S&P500[/TD]
[TD]Consumer Staples[/TD]
[TD]30%[/TD]
[/TR]
[TR]
[TD]S&P500[/TD]
[TD]Consumer Discretionary[/TD]
[TD]10%[/TD]
[/TR]
[TR]
[TD]Nasdaq100[/TD]
[TD]Technology[/TD]
[TD]15%[/TD]
[/TR]
[TR]
[TD]Nasdaq100[/TD]
[TD]Energy[/TD]
[TD]15%[/TD]
[/TR]
[TR]
[TD]Nasdaq100[/TD]
[TD]Consumer Staples[/TD]
[TD]30%[/TD]
[/TR]
[TR]
[TD]Nasdaq100[/TD]
[TD]Consumer Discretionary[/TD]
[TD]40%[/TD]
[/TR]
</tbody>[/TABLE]
Desired Query result
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]Portfolio components[/TD]
[TD]Balance[/TD]
[/TR]
[TR]
[TD]SPDR -Technology[/TD]
[TD]2,000[/TD]
[/TR]
[TR]
[TD]SPDR -Energy[/TD]
[TD]4,000[/TD]
[/TR]
[TR]
[TD]SPDR -Consumer Staples[/TD]
[TD]3,000[/TD]
[/TR]
[TR]
[TD]SPDR -Consumer Discretionary[/TD]
[TD]1,000[/TD]
[/TR]
[TR]
[TD]AAPL[/TD]
[TD]5,000[/TD]
[/TR]
[TR]
[TD]MSFT[/TD]
[TD]4,000[/TD]
[/TR]
[TR]
[TD]QQQ -Technology[/TD]
[TD]300[/TD]
[/TR]
[TR]
[TD]QQQ -Energy[/TD]
[TD]450[/TD]
[/TR]
[TR]
[TD]QQQ -Consumer Staples[/TD]
[TD]450[/TD]
[/TR]
[TR]
[TD]QQQ -Consumer Discretionary[/TD]
[TD]900[/TD]
[/TR]
</tbody>[/TABLE]
I want to know if there's a way to brake-down to components a data table according to weight?
I have a portfolio of equities and etf's (table 1) , and I want that every ETF in it will be 'opened' according to the weights (table 3) of its related index (table 2) , so I'll get a table like in the 'Desired Query'.
Is that doable?
Thanks in advance
Table 1
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]Portfolio components[/TD]
[TD]Balance[/TD]
[/TR]
[TR]
[TD]SPDR[/TD]
[TD]10,000[/TD]
[/TR]
[TR]
[TD]AAPL[/TD]
[TD]5,000[/TD]
[/TR]
[TR]
[TD]MSFT[/TD]
[TD]4,000[/TD]
[/TR]
[TR]
[TD]QQQ[/TD]
[TD]3,000[/TD]
[/TR]
</tbody>[/TABLE]
Table 2
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]Portfolio components[/TD]
[TD]Linked Index[/TD]
[/TR]
[TR]
[TD]SPDR[/TD]
[TD]S&P500[/TD]
[/TR]
[TR]
[TD]QQQ[/TD]
[TD]Nasdaq100[/TD]
[/TR]
</tbody>[/TABLE]
Table 4
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]Index[/TD]
[TD]Sector[/TD]
[TD]Weight[/TD]
[/TR]
[TR]
[TD]S&P500[/TD]
[TD]Technology[/TD]
[TD]20%[/TD]
[/TR]
[TR]
[TD]S&P500[/TD]
[TD]Energy[/TD]
[TD]40%[/TD]
[/TR]
[TR]
[TD]S&P500[/TD]
[TD]Consumer Staples[/TD]
[TD]30%[/TD]
[/TR]
[TR]
[TD]S&P500[/TD]
[TD]Consumer Discretionary[/TD]
[TD]10%[/TD]
[/TR]
[TR]
[TD]Nasdaq100[/TD]
[TD]Technology[/TD]
[TD]15%[/TD]
[/TR]
[TR]
[TD]Nasdaq100[/TD]
[TD]Energy[/TD]
[TD]15%[/TD]
[/TR]
[TR]
[TD]Nasdaq100[/TD]
[TD]Consumer Staples[/TD]
[TD]30%[/TD]
[/TR]
[TR]
[TD]Nasdaq100[/TD]
[TD]Consumer Discretionary[/TD]
[TD]40%[/TD]
[/TR]
</tbody>[/TABLE]
Desired Query result
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]Portfolio components[/TD]
[TD]Balance[/TD]
[/TR]
[TR]
[TD]SPDR -Technology[/TD]
[TD]2,000[/TD]
[/TR]
[TR]
[TD]SPDR -Energy[/TD]
[TD]4,000[/TD]
[/TR]
[TR]
[TD]SPDR -Consumer Staples[/TD]
[TD]3,000[/TD]
[/TR]
[TR]
[TD]SPDR -Consumer Discretionary[/TD]
[TD]1,000[/TD]
[/TR]
[TR]
[TD]AAPL[/TD]
[TD]5,000[/TD]
[/TR]
[TR]
[TD]MSFT[/TD]
[TD]4,000[/TD]
[/TR]
[TR]
[TD]QQQ -Technology[/TD]
[TD]300[/TD]
[/TR]
[TR]
[TD]QQQ -Energy[/TD]
[TD]450[/TD]
[/TR]
[TR]
[TD]QQQ -Consumer Staples[/TD]
[TD]450[/TD]
[/TR]
[TR]
[TD]QQQ -Consumer Discretionary[/TD]
[TD]900[/TD]
[/TR]
</tbody>[/TABLE]
Last edited: