+ Reply to Thread
Results 1 to 7 of 7

Find Avg of weighted values, dependent on multiple criteria, with weightings in 3rd table

  1. #1
    Registered User
    Join Date
    08-16-2017
    Location
    Toronto, Canada
    MS-Off Ver
    2016
    Posts
    5

    Cool Find Avg of weighted values, dependent on multiple criteria, with weightings in 3rd table

    Hi Guys,
    First post, hope I'm doing this right!

    I have Table1 which contains the values I need to Average into a column in Table2. The selection of rows in Table1 for the Avg is based on multiple criteria matching every row of Table2.

    My problem is with solving the requirement for me to use weighting in the Average calculation. Table1 contains two columns, which combined can be used to look up matching values in a third table, Table3. Table3 provides the weighting value that I want to use in Table2's function that gets the Average from Table1.

    Normally I would have accomplished this using Sumproduct, so naturally I tried to add an Index Match Array function to get the weighting value and multiple against the avg column, but because I have multiple criteria I needed to use an array function, and gave an error, which I think is because Sumproduct can't be used that way.

    Here's my function in [Table2]:
    =SUMPRODUCT(
    Table1[Cost] *
    ([@Provider]= Table1[Provider]) *
    ([@Term]= Table1[Term])
    ) /
    COUNTIFS(
    Table1[Provider], [@Provider],
    Table1[Term], [@Term])

    Here's the formula that does not work where I've attempted to get the weight:
    =SUMPRODUCT(
    (Table1[Cost] * INDEX(Table3[Weight], MATCH(1, (Table1[Provider] = Table3[Provider]) * ( Table1[Category] = Table3[Category]), 0))) *
    ([@Provider] = Table1[Provider]) *
    ([@Term] = Table1[Term])
    ) /
    COUNTIFS(
    Table1[Provider], [@Provider],
    Table1[Term], [@Term])

    This also doesn't work:
    =SUMPRODUCT(
    Table1[Cost] *
    ([@Provider]= Table1[Provider]) *
    ([@Term]= Table1[Term]) ,
    (Table1[Category] = Table3[Category]) *
    ([Provider] = Table3[Provider])
    ) /
    COUNTIFS(
    Table1[Provider], [@Provider],
    Table1[Term], [@Term])


    Spreadsheet attached with example.

    Thank you!
    Attached Images Attached Images
    Attached Files Attached Files
    Last edited by butterpouch; 08-16-2017 at 10:02 PM.
    YAwn, is today over yet?

  2. #2
    Forum Expert
    Join Date
    01-05-2013
    Location
    Singapore
    MS-Off Ver
    H&B2016 & H&B2021
    Posts
    3,059

    Re: Find Avg of weighted values, dependent on multiple criteria, with weightings in 3rd ta

    [removed post]
    Last edited by josephteh; 08-16-2017 at 11:03 PM.

  3. #3
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,562

    Re: Find Avg of weighted values, dependent on multiple criteria, with weightings in 3rd ta

    Hello butterpouch and Welcome to Excel forum.
    This proposed solution employs a helper column, which may be hidden for aesthetic purposes.
    The array entered formula that populates the helper column (H) is:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    If I understand what you want correctly then the formula that should populate the 'Average Weighted Cost' column on table 2 is:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    If I have misunderstood then please post the expected value for at least cell L4.
    Let us know if you have any questions.
    Last edited by JeteMc; 08-17-2017 at 01:47 AM. Reason: Correcting error in formula and file
    Consider taking the time to add to the reputation of everybody that has taken the time to respond to your query.

  4. #4
    Forum Expert shukla.ankur281190's Avatar
    Join Date
    05-17-2014
    Location
    Lucknow, India
    MS-Off Ver
    Office 365
    Posts
    3,935

    Re: Find Avg of weighted values, dependent on multiple criteria, with weightings in 3rd ta

    Due to mess-up with range issue, I converted table format into ranges.

    Try

    K3
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    ...confirmed by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER. You will know the array is active when you see curly braces { } appear around your formula. If you do not CTRL+SHIFT+ENTER you will get an error or a clearly incorrect answer.

    Check the attached file.
    Attached Files Attached Files
    If I helped, Don't forget to add reputation (click on the little star ★ at bottom of this post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)

  5. #5
    Registered User
    Join Date
    08-16-2017
    Location
    Toronto, Canada
    MS-Off Ver
    2016
    Posts
    5

    Re: Find Avg of weighted values, dependent on multiple criteria, with weightings in 3rd ta

    Thank you JeteMc,
    Not exactly what I'm looking for, but close. @Category doesn't exist in Table2, to get it I have to lookup Table1. That lookup from Table2 to Table1 may return many results, and I then want to multiply each one against a weight value by performing yet another lookup from Table1 to Table3, however in this case there should only be one result. In your solution I believe it relies on adding a column to Table1 matching with a single record in Table3 to get the weighting, but I can't actually make changes to Table1 in this scenario.

    Table1 comes from a data connection, and I'm not able to modify it. Table2 and Table3 however I can modify.

    Finally, for the result in L4 I would expect the same result you have provided, so that is correct. The only issue is I can't modify Table1

    Quote Originally Posted by JeteMc View Post
    Hello butterpouch and Welcome to Excel forum.
    This proposed solution employs a helper column, which may be hidden for aesthetic purposes.
    The array entered formula that populates the helper column (H) is:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    If I understand what you want correctly then the formula that should populate the 'Average Weighted Cost' column on table 2 is:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    If I have misunderstood then please post the expected value for at least cell L4.
    Let us know if you have any questions.
    Last edited by butterpouch; 08-17-2017 at 10:34 AM.

  6. #6
    Registered User
    Join Date
    08-16-2017
    Location
    Toronto, Canada
    MS-Off Ver
    2016
    Posts
    5

    Re: Find Avg of weighted values, dependent on multiple criteria, with weightings in 3rd ta

    Hi Shukla,

    Thank you very much! I removed the countif division and the result is perfect. I should have clarified that I'm looking for a result of 18.9561 in K4 and I'm sure you would have figured that out:

    {=SUMPRODUCT(($D$3:$D$17=I4)*($E$3:$E$17=J4)*IF($D$3:$D$17=TRANSPOSE($M$3:$M$7),IF($G$3:$G$17=TRANSPOSE($N$3:$N$7),TRANSPOSE($O$3:$O$7)*$F$3:$F$17,0),0))}


    Quote Originally Posted by shukla.ankur281190 View Post
    Due to mess-up with range issue, I converted table format into ranges.

    Try

    K3
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    ...confirmed by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER. You will know the array is active when you see curly braces { } appear around your formula. If you do not CTRL+SHIFT+ENTER you will get an error or a clearly incorrect answer.

    Check the attached file.

  7. #7
    Registered User
    Join Date
    08-16-2017
    Location
    Toronto, Canada
    MS-Off Ver
    2016
    Posts
    5

    Re: Find Avg of weighted values, dependent on multiple criteria, with weightings in 3rd ta

    My final solution came from the response provided by shula.ankur281190 (Thank you!)

    Please Login or Register  to view this content.
    Final solution attached
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Weighted average using multiple criteria matches
    By mmayo713 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 08-02-2016, 01:52 PM
  2. Weighted averages with multiple criteria
    By Jps62 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 08-29-2015, 03:50 PM
  3. Replies: 0
    Last Post: 07-01-2015, 09:49 AM
  4. Replies: 2
    Last Post: 05-26-2015, 07:29 PM
  5. Replies: 0
    Last Post: 05-21-2012, 04:03 AM
  6. Find nth occurence in a table with multiple criteria
    By efernandes67 in forum Excel General
    Replies: 2
    Last Post: 02-01-2011, 05:36 PM
  7. summing table values with multiple criteria from a dynamic table
    By griffith in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 05-06-2005, 05:51 PM

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