Small but hard Challenge

Morosho

New Member
Joined
Mar 10, 2015
Messages
3
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:

Client nameBrokerShareClient&ShareQuantityAvg Price (in Broker)Avg Price (Client)
DanXAAPLDanAAPL10090formula?
DanXTDanT5040?
JhonYAAPLJhonE8088?
DanYAAPLDanAAPL20095?
etc...etc...etc...etc...etc...etc...

<tbody>
</tbody>

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?
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
Maybe?
Excel Workbook
ABCDEFG
1nameBrokerShareClient&ShareQuantityAvg Price (in Broker)Avg Price (Client)
2DanXAAPLDanAAPL1009093.33
3DanXTDanT504040.00
4JhonYAAPLJhonE808888.00
5DanYAAPLDanAAPL2009593.33
Sheet
 
Upvote 0
Man, you are great... I had not seen this "Range=Cell" trick before. Does this have a special name to start reading about it? Because it's Fing awesome!

Thanks!

Edit: what's the " -- " for? what does it do?
 
Last edited:
Upvote 0
Man, you are great... I had not seen this "Range=Cell" trick before. Does this have a special name to start reading about it? Because it's Fing awesome!
In general, the are "array formulas" which normally need to be array-entered pressing CTRL+SHIFT+ENTER instead of just Enter by itself; however, SUMPRODUCT is a special function in that it natively handles array formulas without the need to array-enter them. See here for more information on array formulas...

Array Formulas
 
Upvote 0
You're welcome, glad that worked for you. As per Morosho the -- just multiples the TRUE and FALSE by 1 to turn them into 1 and 0.
 
Upvote 0

Forum statistics

Threads
1,215,372
Messages
6,124,541
Members
449,169
Latest member
mm424

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