#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 97
Default Conditional sumif?

Hi,

I am looking for a formula that will allow me to calculate a weighted
average price. The data is as follows:

Vol Price Price x Vol
27 50 1350
30 45 1350
15 60 900
20 40 800

Total Vol: 92
Weighted average: 47.83 (sum(vol * price) / total vol)

However, occasionally I have negative volumes (i.e. buy or sell) and want
the formula to calculate only the positive/negative weighted prices dependent
on the total vol (the example above is positive with a total vol of 92).
Using the data above, if there was a negative volume included in the data, it
would look like:

Vol Price Price x Vol
27 50 1350
30 45 1350
15 60 900
20 40 800
-50 20 -1000

Total Vol: 42
Weighted average: 80.95 (sum(vol * price) / total vol)

....but I want the formula to ignore the -50 volume. I want to avoid using
helper columns etc, and was thinking there may be a way of doing something
along the lines of: if(total vol < 0 , (sum -ve prices * vols)/total -ve
vols, (sum +ve prices * vols)/total +ve vols), but can't work out how to do
it. Any help appreciated...
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,203
Default Conditional sumif?

I wrote the formula a bit oddly, assumes that your first vol/price pair is on
row 9 and the -50 volume entry is in row 13, adjust accordingly:

=SUMPRODUCT(--(C9:C130),(C9:C13))/SUMPRODUCT(--(A9:A130),(A9:A13))

I think that'll do the trick for you without resorting to array formulas.


"ewan7279" wrote:

Hi,

I am looking for a formula that will allow me to calculate a weighted
average price. The data is as follows:

Vol Price Price x Vol
27 50 1350
30 45 1350
15 60 900
20 40 800

Total Vol: 92
Weighted average: 47.83 (sum(vol * price) / total vol)

However, occasionally I have negative volumes (i.e. buy or sell) and want
the formula to calculate only the positive/negative weighted prices dependent
on the total vol (the example above is positive with a total vol of 92).
Using the data above, if there was a negative volume included in the data, it
would look like:

Vol Price Price x Vol
27 50 1350
30 45 1350
15 60 900
20 40 800
-50 20 -1000

Total Vol: 42
Weighted average: 80.95 (sum(vol * price) / total vol)

...but I want the formula to ignore the -50 volume. I want to avoid using
helper columns etc, and was thinking there may be a way of doing something
along the lines of: if(total vol < 0 , (sum -ve prices * vols)/total -ve
vols, (sum +ve prices * vols)/total +ve vols), but can't work out how to do
it. Any help appreciated...

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,572
Default Conditional sumif?

=SUMIF(C9:C13,"0")/SUMIF(A9:A13,"0")
--

HTH,

RD
================================================== ===
Please keep all correspondence within the Group, so all may benefit!
================================================== ===

"ewan7279" wrote in message
...
Hi,

I am looking for a formula that will allow me to calculate a weighted
average price. The data is as follows:

Vol Price Price x Vol
27 50 1350
30 45 1350
15 60 900
20 40 800

Total Vol: 92
Weighted average: 47.83 (sum(vol * price) / total vol)

However, occasionally I have negative volumes (i.e. buy or sell) and want
the formula to calculate only the positive/negative weighted prices
dependent
on the total vol (the example above is positive with a total vol of 92).
Using the data above, if there was a negative volume included in the data,
it
would look like:

Vol Price Price x Vol
27 50 1350
30 45 1350
15 60 900
20 40 800
-50 20 -1000

Total Vol: 42
Weighted average: 80.95 (sum(vol * price) / total vol)

....but I want the formula to ignore the -50 volume. I want to avoid using
helper columns etc, and was thinking there may be a way of doing something
along the lines of: if(total vol < 0 , (sum -ve prices * vols)/total -ve
vols, (sum +ve prices * vols)/total +ve vols), but can't work out how to do
it. Any help appreciated...


  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,346
Default Conditional sumif?

Hi,

The basic weighted average formula would be

=SUMPRODUCT(A2:A9*B2:B9)/SUM(B2:B9)

You can make this condtional with:

=SUMPRODUCT(--(A2:A9<0),A2:A9*B2:B9)/SUMPRODUCT(B2:B9*(A2:A9<0))

--
If this helps, please click the Yes button.

Cheers,
Shane Devenshire


"ewan7279" wrote:

Hi,

I am looking for a formula that will allow me to calculate a weighted
average price. The data is as follows:

Vol Price Price x Vol
27 50 1350
30 45 1350
15 60 900
20 40 800

Total Vol: 92
Weighted average: 47.83 (sum(vol * price) / total vol)

However, occasionally I have negative volumes (i.e. buy or sell) and want
the formula to calculate only the positive/negative weighted prices dependent
on the total vol (the example above is positive with a total vol of 92).
Using the data above, if there was a negative volume included in the data, it
would look like:

Vol Price Price x Vol
27 50 1350
30 45 1350
15 60 900
20 40 800
-50 20 -1000

Total Vol: 42
Weighted average: 80.95 (sum(vol * price) / total vol)

...but I want the formula to ignore the -50 volume. I want to avoid using
helper columns etc, and was thinking there may be a way of doing something
along the lines of: if(total vol < 0 , (sum -ve prices * vols)/total -ve
vols, (sum +ve prices * vols)/total +ve vols), but can't work out how to do
it. Any help appreciated...

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 97
Default Conditional sumif?

Thanks for your reply.

Your answer works in the example I gave you, but I might not have expanded
my question far enough - can the formula be written so that if the total vol
is negative, all positive figures are excluded? I have tried the formula on
the data below, and I get a #div/0! error (would expect to have 27.82 as an
answer):

Vol Price Price * Vol
-35 28 -980
-97 27 -2619
-40 27 -1080
-89 29 -2581

Total vol: -261


"JLatham" wrote:

I wrote the formula a bit oddly, assumes that your first vol/price pair is on
row 9 and the -50 volume entry is in row 13, adjust accordingly:

=SUMPRODUCT(--(C9:C130),(C9:C13))/SUMPRODUCT(--(A9:A130),(A9:A13))

I think that'll do the trick for you without resorting to array formulas.


"ewan7279" wrote:

Hi,

I am looking for a formula that will allow me to calculate a weighted
average price. The data is as follows:

Vol Price Price x Vol
27 50 1350
30 45 1350
15 60 900
20 40 800

Total Vol: 92
Weighted average: 47.83 (sum(vol * price) / total vol)

However, occasionally I have negative volumes (i.e. buy or sell) and want
the formula to calculate only the positive/negative weighted prices dependent
on the total vol (the example above is positive with a total vol of 92).
Using the data above, if there was a negative volume included in the data, it
would look like:

Vol Price Price x Vol
27 50 1350
30 45 1350
15 60 900
20 40 800
-50 20 -1000

Total Vol: 42
Weighted average: 80.95 (sum(vol * price) / total vol)

...but I want the formula to ignore the -50 volume. I want to avoid using
helper columns etc, and was thinking there may be a way of doing something
along the lines of: if(total vol < 0 , (sum -ve prices * vols)/total -ve
vols, (sum +ve prices * vols)/total +ve vols), but can't work out how to do
it. Any help appreciated...



  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 97
Default Conditional sumif?

Great! So simple...thanks. Final formula is:

=IF(L10,SUMIF(J3:J320,"0")/SUMIF(H3:H320,"0"),SUMIF(J3:J320,"<0")/SUMIF(H3:H320,"<0"))

"RagDyeR" wrote:

=SUMIF(C9:C13,"0")/SUMIF(A9:A13,"0")
--

HTH,

RD
================================================== ===
Please keep all correspondence within the Group, so all may benefit!
================================================== ===

"ewan7279" wrote in message
...
Hi,

I am looking for a formula that will allow me to calculate a weighted
average price. The data is as follows:

Vol Price Price x Vol
27 50 1350
30 45 1350
15 60 900
20 40 800

Total Vol: 92
Weighted average: 47.83 (sum(vol * price) / total vol)

However, occasionally I have negative volumes (i.e. buy or sell) and want
the formula to calculate only the positive/negative weighted prices
dependent
on the total vol (the example above is positive with a total vol of 92).
Using the data above, if there was a negative volume included in the data,
it
would look like:

Vol Price Price x Vol
27 50 1350
30 45 1350
15 60 900
20 40 800
-50 20 -1000

Total Vol: 42
Weighted average: 80.95 (sum(vol * price) / total vol)

....but I want the formula to ignore the -50 volume. I want to avoid using
helper columns etc, and was thinking there may be a way of doing something
along the lines of: if(total vol < 0 , (sum -ve prices * vols)/total -ve
vols, (sum +ve prices * vols)/total +ve vols), but can't work out how to do
it. Any help appreciated...



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Conditional formatting w/ a sumif hmsawyer Excel Discussion (Misc queries) 1 March 25th 08 03:50 PM
Conditional sumif wilson@irco Excel Discussion (Misc queries) 3 March 7th 06 10:17 PM
conditional fraction - sumif? Lee Harris Excel Worksheet Functions 4 November 16th 05 05:43 AM
Conditional SUMIF??? DaveO Excel Worksheet Functions 5 November 11th 05 01:56 PM
Conditional SUMIF Curtis Excel Worksheet Functions 8 September 26th 05 09:50 PM


All times are GMT +1. The time now is 08:29 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"