+ Reply to Thread
Results 1 to 6 of 6

subtotal and weighted average

  1. #1
    Registered User
    Join Date
    08-07-2011
    Location
    london, england
    MS-Off Ver
    Excel 2003
    Posts
    34

    subtotal and weighted average

    Hi,

    I have Columns A and B.

    I want to compute the weighted average of column A. Column B are the weights.

    The formula should look something like A*B/(sumB)
    I tried

    Please Login or Register  to view this content.
    I need subtotal because of the ability to filter. It seems to get stuck really just at SUBTOTAL(6,A:A,B:B) because I have a lot of data, and the max number is something like 3 e 300. Help?

    Thanks,
    Matthew

  2. #2
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: subtotal and weighted average

    Try:

    =SUMPRODUCT(SUBTOTAL(9,OFFSET(A1:A11,ROW(A1:A11)-MIN(ROW(A1:A11)),,1)),A1:A11,B1:B11)/SUBTOTAL(9,B1:B11)

    adjust ranges to suit... it is not recommended to use full column references because of efficiency loss....(and you can't anyway with 2003 version)
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  3. #3
    Registered User
    Join Date
    08-07-2011
    Location
    london, england
    MS-Off Ver
    Excel 2003
    Posts
    34

    Re: subtotal and weighted average

    Hi,

    Thanks for your reply.

    1) My original idea doesn't make any sense bc i thought 6 (for product) did sumproduct, but it doesn't
    2) I dont' totally understand NBVC's idea. When I try it, it evaulates to True

    Is there a way to get an array of just the filtered numbers?

    Also I have excel 2010.

  4. #4
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: subtotal and weighted average

    Attachment 152883See attached for another sample.

    This one based on filter being in a different column, like filtering for "b" in column C...

    formula would be:

    =SUMPRODUCT(SUBTOTAL(9,OFFSET(A2:A11,ROW(C2:C11)-MIN(ROW(C2:C11)),,1)),B2:B11)/SUBTOTAL(9,A2:A11)

    edit... realized I used count in the denominator instead of Sum (i.e. SUBTOTAL(9....))
    Attached Files Attached Files
    Last edited by NBVC; 04-27-2012 at 05:02 PM.

  5. #5
    Registered User
    Join Date
    08-07-2011
    Location
    london, england
    MS-Off Ver
    Excel 2003
    Posts
    34

    Re: subtotal and weighted average

    ok it works, but i still can't figure out what is going on in that formula. would you mind explaining?

    Thanks so much

  6. #6
    Registered User
    Join Date
    08-07-2011
    Location
    london, england
    MS-Off Ver
    Excel 2003
    Posts
    34

    Re: subtotal and weighted average

    also is there a reason why, in the formulas you have up to 11, even though the numbers in A,B,C only go up to 10?

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1