Hey guys, I have been using excel for a long time now and I consider myself relatively good at it.
However I have been having a headache trying to solve a kind of complex weighted average in a table like this:
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]Client name[/TD]
[TD]Broker[/TD]
[TD]Share[/TD]
[TD]Client&Share[/TD]
[TD]Quantity[/TD]
[TD]Avg Price (in Broker)[/TD]
[TD]Avg Price (Client)[/TD]
[/TR]
[TR]
[TD]Dan[/TD]
[TD]X[/TD]
[TD]AAPL[/TD]
[TD]DanAAPL[/TD]
[TD]100[/TD]
[TD]90[/TD]
[TD]formula?[/TD]
[/TR]
[TR]
[TD]Dan[/TD]
[TD]X[/TD]
[TD]T[/TD]
[TD]DanT[/TD]
[TD]50[/TD]
[TD]40[/TD]
[TD]?[/TD]
[/TR]
[TR]
[TD]Jhon[/TD]
[TD]Y[/TD]
[TD]AAPL[/TD]
[TD]JhonE[/TD]
[TD]80[/TD]
[TD]88[/TD]
[TD]?[/TD]
[/TR]
[TR]
[TD]Dan[/TD]
[TD]Y[/TD]
[TD]AAPL[/TD]
[TD]DanAAPL[/TD]
[TD]200[/TD]
[TD]95[/TD]
[TD]?[/TD]
[/TR]
[TR]
[TD]etc...[/TD]
[TD]etc...[/TD]
[TD]etc...[/TD]
[TD]etc...[/TD]
[TD]etc...[/TD]
[TD]etc...[/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
The result for first row in column "Avg Price (Client)" would be ((100*90)+(200*95))/(100+200) = 93.33
It should also show the same result for row #4 in that formula (93.33)
Most clients have accounts in 3+ brokers, so that makes it a little more complicated... (in the example here it's only two)
I have some formula that gives an aprox value.. but I need the real weighted average.
Just to show I have tried, this is what I got: =IF([@Precio]=0;0;([@Cantidad]*[@Precio]+((SUMIF([D&A];[@[D&A]];[Cantidad])-[@Cantidad])*(SUMIF([D&A];[@[D&A]];[Precio])-[@Precio]))/(COUNTIF([D&A];[@[D&A]])-IF(COUNTIF([D&A];[@[D&A]])=1;0;1)))/SUMIF([D&A];[@[D&A]];[Cantidad]))
Anyone with some inspiration to help me?
However I have been having a headache trying to solve a kind of complex weighted average in a table like this:
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]Client name[/TD]
[TD]Broker[/TD]
[TD]Share[/TD]
[TD]Client&Share[/TD]
[TD]Quantity[/TD]
[TD]Avg Price (in Broker)[/TD]
[TD]Avg Price (Client)[/TD]
[/TR]
[TR]
[TD]Dan[/TD]
[TD]X[/TD]
[TD]AAPL[/TD]
[TD]DanAAPL[/TD]
[TD]100[/TD]
[TD]90[/TD]
[TD]formula?[/TD]
[/TR]
[TR]
[TD]Dan[/TD]
[TD]X[/TD]
[TD]T[/TD]
[TD]DanT[/TD]
[TD]50[/TD]
[TD]40[/TD]
[TD]?[/TD]
[/TR]
[TR]
[TD]Jhon[/TD]
[TD]Y[/TD]
[TD]AAPL[/TD]
[TD]JhonE[/TD]
[TD]80[/TD]
[TD]88[/TD]
[TD]?[/TD]
[/TR]
[TR]
[TD]Dan[/TD]
[TD]Y[/TD]
[TD]AAPL[/TD]
[TD]DanAAPL[/TD]
[TD]200[/TD]
[TD]95[/TD]
[TD]?[/TD]
[/TR]
[TR]
[TD]etc...[/TD]
[TD]etc...[/TD]
[TD]etc...[/TD]
[TD]etc...[/TD]
[TD]etc...[/TD]
[TD]etc...[/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
The result for first row in column "Avg Price (Client)" would be ((100*90)+(200*95))/(100+200) = 93.33
It should also show the same result for row #4 in that formula (93.33)
Most clients have accounts in 3+ brokers, so that makes it a little more complicated... (in the example here it's only two)
I have some formula that gives an aprox value.. but I need the real weighted average.
Just to show I have tried, this is what I got: =IF([@Precio]=0;0;([@Cantidad]*[@Precio]+((SUMIF([D&A];[@[D&A]];[Cantidad])-[@Cantidad])*(SUMIF([D&A];[@[D&A]];[Precio])-[@Precio]))/(COUNTIF([D&A];[@[D&A]])-IF(COUNTIF([D&A];[@[D&A]])=1;0;1)))/SUMIF([D&A];[@[D&A]];[Cantidad]))
Anyone with some inspiration to help me?