Solved

excel calculation

Posted on 2011-03-01
15
269 Views
Last Modified: 2012-05-11
Is there a simple formula for figuring this out, the sum of the rows?  See below for further explanation:

A      B      C      D

S      825.2      1      3/1/2011 14:34
B      824.8      1      3/1/2011 14:35
B      821.2      1      3/1/2011 14:41
S      821.1      1      3/1/2011 14:41

The above columns show trading contracts.  

Column A is S or B, meaning short or long.  An S contract is a negative amount and a B contract is a positive amount.  

Column B is the contract value.

Column  C is the quantity of contracts traded

Column D is the date and doesn't matter for this calculation.

If the formula is working correctly, I would be able to select rows 1 and 2 and apply the formula and get a sum of 4 in Column E
0
Comment
Question by:rodynetwork
  • 7
  • 4
  • 4
15 Comments
 

Author Comment

by:rodynetwork
ID: 35012650
Sorry, to further explain, I would get a sum of 4 because the contract has a multiplier of 10.  Forgot to mention that....so, -825.2 + 824.8=.4 and .4 is really 4 because of the multiplier inherent in the contract traded.
0
 
LVL 24

Expert Comment

by:StephenJR
ID: 35012677
Do you mean -4?

=10*(SUMIF($A$1:$A$2,"S",$B$1:$B$2)*-1+SUMIF($A$1:$A$2,"B",$B$1:$B$2))

0
 
LVL 24

Expert Comment

by:StephenJR
ID: 35012704
But this doesn't take quantity into account.
0
 
LVL 24

Expert Comment

by:StephenJR
ID: 35012717
So this might be better?

=10*(-1*SUMPRODUCT((A1:A2="S")*(B1:B2)*(C1:C2))+SUMPRODUCT((A1:A2="B")*(B1:B2)*(C1:C2)))
0
 
LVL 50

Expert Comment

by:barry houdini
ID: 35012727
Try

=SUMPRODUCT((A1:A2={"S","B"})*{-1,1}*C1:C2*B1:B2)*10

regards, barry
0
 
LVL 24

Expert Comment

by:StephenJR
ID: 35012749
Very neat Barry, I wouldn't have come up with that in a month of Sundays.
0
 

Author Comment

by:rodynetwork
ID: 35012847
I am sorry.  The way I explained it is confusing. The short means I sold a contract whose value was 825.2 and later I bought a contract at 824.8, liquidating my position and giving me a net gain of .4 or 4.  The way I illustrated it earlier was not correct.

Next thing, I am pretty excel ignorant, so how do I apply the formulat?  I copy/pasted it into E, row 2 and get a -4, but am finding that any row I paste it, it gives the same answer, so I am assuming I am applying the formula incorrectly.  Do I need to insert it somewhere? I am using MS Office 2007.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:rodynetwork
ID: 35012852
Sorry, another consideration, I have 64 rows to apply this to for today.  Tomorrow may be more or less rows....
0
 
LVL 50

Expert Comment

by:barry houdini
ID: 35012906
If you want to copy the formula down so that it applies to all rows above try like this in row 2 copied down

=SUMPRODUCT((A$1:A2={"S","B"})*{1,-1}*C$1:C2*B$1:B2)*10

regards, barry

0
 

Author Comment

by:rodynetwork
ID: 35012975
I took a picture of what I am getting.  Notice column D info changed, not sure why. Also, notice I am copying/pasting the formula into E2 and then drag/copying down from there.  
2011-03-01-1731.png
0
 

Author Comment

by:rodynetwork
ID: 35012981
Nevermind that last, now getting this. Think we are closer....
2011-03-01-1736.png
0
 

Author Comment

by:rodynetwork
ID: 35013020

I think your formula is working, as row 24 is correct, I was up 30 at that time. Not sure what to make of the number that appears on every odd row in Column E

0
 
LVL 50

Expert Comment

by:barry houdini
ID: 35013041
OK, I hesitate to say this but aren't they the correct values? Presumably the large positive or negative values are unexpected but they just indicate that you have bought without yet selling....or vice versa, perhaps you can only show the value if the number of Bs and Ss are the same (although does that necessarily apply to the same contract?), e.g. formula could be

=IF(SUM(COUNTIF(A$1:A2,{"S","B"})*{1,-1}),SUMPRODUCT((A$1:A2={"S","B"})*{1,-1}*C$1:C2*B$1:B2)*10,"")

regards, barry
0
 
LVL 50

Accepted Solution

by:
barry houdini earned 500 total points
ID: 35013051
Sorry, cancel that, error in formula, should be

=IF(SUM(COUNTIF(A$1:A2,{"S","B"})*{1,-1}),"",SUMPRODUCT((A$1:A2={"S","B"})*{1,-1}*C$1:C2*B$1:B2)*10)

regards, barry
0
 

Author Comment

by:rodynetwork
ID: 35013122
that did it. works perfectly.  Thanks.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Moving Excel to AaaS 4 37
Boolean help 6 27
macro for closing opened workbook 6 20
Excel 2010 - Comparison of texts in a cell 14 36
Drop Down List with Unique/Distinct Values (enhancing the Combo-Box with a few steps and a little code) David miller (dlmille) Intro Have you ever created a data validation list from a database field or spreadsheet column (e.g., Zip Codes or Co…
Convert between Excel file formats (.XLS, .XLSX, .XLSM) with/without macro option David Miller (dlmille) Intro Over this past Fall, I've had the opportunity to see several similar requests and have developed a couple related solutions associate…
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now