+ Reply to Thread
Results 1 to 5 of 5

Excel 2007 : Weighted Average Price - FILTERED

  1. #1
    Registered User
    Join Date
    09-22-2009
    Location
    Mumbai India
    MS-Off Ver
    Excel 2007 & 2010
    Posts
    77

    Weighted Average Price - FILTERED

    I am using this function to feed back the weighted average prices:

    =SUMPRODUCT(Price per unit Range,Number of units Range)/SUM(Number of units Range)

    However, I have filters at the top of my sheet to turn visibility on and off various products. If I used a SUBTOTAL function it only calculates the visible cells - GREAT!

    Is there a way I can use my weighted average formula ONLY on visible cells when using filters?

    Current formula in use is:

    =SUMPRODUCT(M2:M91,H2:H91)/SUM(H2:H91)

    Solution not working:

    =SUMPRODUCT(SUBTOTAL(9,OFFSET($M$2:$M$91,ROW($M$2:$M$91)-MIN(ROW($M$2:$M$91)),0,1)),$M$2:$M$91,$H$2:$H$91)/SUBTOTAL(9,$H$2:$H$91)

    When filtered shows same result every time. What is wrong?
    Attached Files Attached Files
    Last edited by smudgepost; 06-18-2010 at 11:17 AM. Reason: Added one potential solution, Attached sample worksheet

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Weighted Average Price - FILTERED

    You need only account for the M range once - ie via the SUBTOTAL SUM call.

    Using your sample formula:

    =SUMPRODUCT(SUBTOTAL(9,OFFSET($M$2:$M$91,ROW($M$2:$M$91)-MIN(ROW($M$2:$M$91)),0,1)),$H$2:$H$91)/SUBTOTAL(9,$H$2:$H$91)

    Using the version within the file (different range references)

    =SUMPRODUCT(SUBTOTAL(9,OFFSET($M$3:$M$300,ROW($M$3:$M$300)-MIN(ROW($M$3:$M$300)),0,1)),$F$3:$F$300)/SUBTOTAL(9,$F$3:$F$300)

  3. #3
    Registered User
    Join Date
    09-22-2009
    Location
    Mumbai India
    MS-Off Ver
    Excel 2007 & 2010
    Posts
    77

    Re: Weighted Average Price - FILTERED

    Thank you for checking. I should have specified that the far right column CORRECT£KG is the correct unit price. All erroneous columns are shaded out in attached.

    After some playing I'm confident the weighted average is correct in the spreadsheet example attached.

    Swap filters on the product code and see the value change. Drag the mouse over the CORRECT£KG range to see the simple average value (at the foot of the worksheet) and you can see the numbers are close but differently weighted.

    A weighted average must be a combination of weights (volumes) and unit prices, so based on this initial formula:

    =SUMPRODUCT(Price per unit Range,Number of units Range)/SUM(Number of units Range)

    The attached expanded formula is correct.
    Attached Files Attached Files

  4. #4
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Weighted Average Price - FILTERED

    I can't determine from your post if you're implying there is an issue or not ?

    The file (& formula) is correct.

    You can verify the calculations by adding some basic formulas:

    With no filter applied (ie all rows visible)

    Please Login or Register  to view this content.
    Your weighted average for visible rows can then also be calculated using a very basic:

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    09-22-2009
    Location
    Mumbai India
    MS-Off Ver
    Excel 2007 & 2010
    Posts
    77

    Re: Weighted Average Price - FILTERED

    Apologies, I was not clear - I believe this worksheet is fully functional. It wasn't initially but is now.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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