+ Reply to Thread
Results 1 to 8 of 8

Weighted Average with Two Lookups

  1. #1
    Registered User
    Join Date
    04-09-2014
    Location
    Los Angles, CA
    MS-Off Ver
    Excel 2013
    Posts
    8

    Weighted Average with Two Lookups

    Hello,

    I'm trying to calculate a weighted average based on one criteria and have been successful thanks to this forum by using an array formula. I'm now trying to add in a second criteria and cannot seem to make it work. Below is the original formula where B5 is the one criteria:

    {=SUM(IF(Detail!$G$2:$G$500=B5,Detail!$C$2:$C$500*Detail!$H$2:$H$500)/SUMIF(Detail!$G$2:$G$500,B5,Detail!$C$2:$C$500))}

    Essentially, I'm trying to take the balance (Column C) x Rating (Column H) / Total Balance (Column C) using 2 criteria (Cells B5 & R5). I've tried the formula below and believe the "AND" part is messing it up. I'm not too familiar with arrays so maybe it can't be done this way. Below is what I've tried:

    {=SUM(IF(AND(Detail!$G$2:$G$500=B5,Detail!$Q$2:$Q$500='Risk Rating'!R5),Detail!$C$2:$C$500*Detail!$H$2:$H$500)/SUMIFS(Detail!$C$2:$C$500,Detail!$G$2:$G$500,'Risk Rating'!B5,Detail!$Q$2:$Q$500,'Risk Rating'!R5))}

    Any help would be appreciated.

    Thanks!

  2. #2
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,942

    Re: Weighted Average with Two Lookups

    Instead of AND in your array formula, try using nested IFs:

    =SUM(IF(Detail!$G$2:$G$500=B5,IF(Detail!$Q$2:$Q$500='Risk Rating'!R5,Detail!$C$2:$C$500*Detail!$H$2:$H$500)))/SUMIFS(Detail!$C$2:$C$500,Detail!$G$2:$G$500,'Risk Rating'!B5,Detail!$Q$2:$Q$500,'Risk Rating'!R5))
    Bernie Deitrick
    Excel MVP 2000-2010

  3. #3
    Registered User
    Join Date
    04-09-2014
    Location
    Los Angles, CA
    MS-Off Ver
    Excel 2013
    Posts
    8

    Re: Weighted Average with Two Lookups

    That worked great. Thanks Bernie for the quick turnaround!

  4. #4
    Registered User
    Join Date
    04-09-2014
    Location
    Los Angles, CA
    MS-Off Ver
    Excel 2013
    Posts
    8

    Re: Weighted Average with Two Lookups

    Ok - I have one more question regarding this. I plan on creating a combo box that will allow the user to select the criteria in cell R5. Let's say for example, the criteria are North, South, East, and West. The user can drop down on one of those and filter by that and by the criteria in cell B5. I would also like to add an "All" criteria - where it just does a weighted average based on cell B5 only. So essentially the formula would look like: If B5 = x and R5 = y, then do the average, but if B5 = x and R5 = "All" then average the entire table based on B5. I modified the formula two posts back to add an "If Error" because when the criteria in B5 wasn't available, I was getting the #DIV/0 error.

    Thanks

  5. #5
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,942

    Re: Weighted Average with Two Lookups

    Array enter:

    =IFERROR(IF('Risk Rating'!R5="All", SUM(IF(Detail!$G$2:$G$500=B5,Detail!$C$2:$C$500*Detail!$H$2:$H$500))/SUMIFS(Detail!$C$2:$C$500,Detail!$G$2:$G$500,'Risk Rating'!B5),SUM(IF(Detail!$G$2:$G$500=B5,IF(Detail!$Q$2:$Q$500='Risk Rating'!R5,Detail!$C$2:$C$500*Detail!$H$2:$H$500)))/SUMIFS(Detail!$C$2:$C$500,Detail!$G$2:$G$500,'Risk Rating'!B5,Detail!$Q$2:$Q$500,'Risk Rating'!R5)),"None")

  6. #6
    Registered User
    Join Date
    04-09-2014
    Location
    Los Angles, CA
    MS-Off Ver
    Excel 2013
    Posts
    8

    Re: Weighted Average with Two Lookups

    Once again - Thank you very much!! This is incredibly helpful.

  7. #7
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Weighted Average with Two Lookups

    Based on your last post in this thread, its apparent that you are satisfied with the solution(s) you've received and have solved your question, but you haven't marked your thread as "SOLVED". I will do it for you this time.

    In future, to mark your thread as Solved, you can do the following -
    Select Thread Tools-> Mark thread as Solved.

    Incase your issue is not solved, you can undo it as follows -
    Select Thread Tools-> Mark thread as Unsolved.

    Also, since you are relatively new to the forum, i would like to inform you that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post which helped you. This adds to the reputation of the person who has taken the time to help you.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  8. #8
    Registered User
    Join Date
    04-09-2014
    Location
    Los Angles, CA
    MS-Off Ver
    Excel 2013
    Posts
    8

    Re: Weighted Average with Two Lookups

    Noted. I was unaware, but will follow this in the future.

    Thanks

+ 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 with NA
    By z10nv1ru5 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 04-12-2013, 06:31 PM
  2. Weighted Average
    By Bob@Sun in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 06-28-2010, 08:49 AM
  3. Weighted Average
    By Toomuchtodo in forum Excel General
    Replies: 6
    Last Post: 06-03-2009, 04:59 PM
  4. Weighted Average
    By phm in forum Excel - New Users/Basics
    Replies: 3
    Last Post: 02-03-2006, 07:45 AM
  5. [SOLVED] What is this kind of average called?-weighted average
    By havocdragon in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 06-24-2005, 01:05 PM

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