Formula for average period calculation

stepan1987

Board Regular
Joined
May 6, 2011
Messages
92
Guys, please help with this tricky one:

I have three columns:
A - quantity of security bought or sold in a transaction
B - OPEN/CLOSE: whether the transaction increased the inventory (positive or negative) or decreased it
C - date of the transation

As the security is being bought or sold its inventory changes (gets positive, negative or nil). When there is a negative inventory (security has been more sold than bought ) a buy is a closing position. The same vice versa: a sell is closing to a positive inventory.
What I need: everytime there is a closing transaction I need to calculate the average holding period for the security.

Say there were buys:
100 1 March
300 5 March
200 9 March

and everything was sold on 11 March

I need the formula to give me 100/600*(10 days)+300/600*(6 days)+200/600*(2 days) = 5.33 days

Say, there was a closing transaction and I need this formula to take date of that closing transaction and then weight the difference between the dates of it and respective opening transactions but BEFORE the previous closing transaction occured.

Hope it makes some sence))
Could you give some ideas what the formula should look like?

Thanks!
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
Hey, Stepan:
I hope I understand your question, and I'm sure someone else can probably provide a better formula, but in the mean time, try this:

Based on the example you gave:
Column A Column C
1. 100 1-march
2. 300 5-march
3. 200 9-march
4. 600 11-march

Format column D to "Number." In cell D1, enter "=(A1/A$4)*(C$4-C1)" and copy down to D3. In cell D4 (or any other cell you prefer) enter =sum(D1:D3).

In the formula, A$4 is the total sales, C$4 represents the date everything is sold.

I hope that helps!

-Juan
 
Upvote 0

Forum statistics

Threads
1,224,602
Messages
6,179,845
Members
452,948
Latest member
UsmanAli786

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