+ Reply to Thread
Results 1 to 16 of 16

Conditional Weighted Average with Multiple Variables

  1. #1
    Registered User
    Join Date
    10-02-2017
    Location
    Toronto
    MS-Off Ver
    2016
    Posts
    10

    Unhappy Conditional Weighted Average with Multiple Variables

    Hey guys,

    Spent about 5 hours or more trying to figure this out.. I don't see myself completing the formula without help.

    I need the weighted average for [(P) Storeys] where the following criteria are met:

    1: [(C) Approved] = "Pending"
    2: [(O) Approved] = "Pending"
    3: [(O) Approved] ="*Divisional*"

    How do I do this?
    My closes success, possibly:

    =SUMPRODUCT((Master[(P) Storeys])*(Master[(C) Approved]={"Pending"})*(Master[(O) Approved]={"Pending","*Divisional*"}))/SUMPRODUCT(--((Master[(C) Approved]={"Pending"})*(Master[(O) Approved]={"Pending","*Divisional*"})))

    .. but it returns as #DIV/0!

  2. #2
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: Conditional Weighted Average with Multiple Variables

    Where you have "*Divisional*", are you using the asterisks as wildcards, I'm assuming so.......

    I can't see how this is a "weighted average", for that you'd need at least two numeric columns (one for the value and one for the weight). What you are describing seems to be a simple average with conditions. You can do that with an array formula like this:

    =AVERAGE(IF(Master[(C) Approved]="Pending",IF((Master[(O) Approved]="Pending")+ISNUMBER(SEARCH("Divisional",Master[(O) Approved])),Master[(P) Storeys])))

    Confirm with CTRL+SHIFT+ENTER

    You can get a non-array version by using SUMIFS/COUNTIFS, i.e.

    =SUM(SUMIFS(Master[(P) Storeys],Master[(C) Approved],"Pending",Master[(O) Approved],{"Pending","*Divisional*"}))/SUM(COUNTIFS(Master[(C) Approved],"Pending",Master[(O) Approved],{"Pending","*Divisional*"}))

    Both formulas should return the same result
    Last edited by daddylonglegs; 10-02-2017 at 02:41 PM.
    Audere est facere

  3. #3
    Registered User
    Join Date
    10-02-2017
    Location
    Toronto
    MS-Off Ver
    2016
    Posts
    10

    Re: Conditional Weighted Average with Multiple Variables

    Quote Originally Posted by daddylonglegs View Post
    Where you have "*Divisional*", are you using the asterisks as wildcards, I'm assuming so.......

    I can't see how this is a "weighted average", for that you'd need at least two numeric columns (one for the value and one for the weight). What you are describing seems to be a simple average with conditions. You can do that with an array formula like this:

    =AVERAGE(IF(Master[(C) Approved]="Pending",IF((Master[(O) Approved]="Pending")+ISNUMBER(SEARCH("Divisional",Master[(O) Approved])),Master[(P) Storeys])))

    Confirm with CTRL+SHIFT+ENTER
    Not sure what I'm doing wrong, but this returns as #DIV/0!

  4. #4
    Registered User
    Join Date
    10-02-2017
    Location
    Toronto
    MS-Off Ver
    2016
    Posts
    10

    Re: Conditional Weighted Average with Multiple Variables

    Quote Originally Posted by Chellobi View Post
    Not sure what I'm doing wrong, but this returns as #DIV/0!
    Sorry.. I may not have clarified myself properly.

    Conditions must be met:

    1: [(C) Approved] = "Pending" OR
    2: [(O) Approved] = "Pending" OR
    3: [(O) Approved] ="*Divisional*"

    So, It's kind of like the weighted (?) average of
    =AVERAGEIF([(C) Approved], "Pending",[(P) Stories] ) + =AVERAGEIF([(O) Approved], "Pending",[(P) Stories] ) + =AVERAGEIF([(O) Approved], "*Divisional*",[(P) Stories] )

    So the weights, I think, come from the fact that each group has a different count... the weight I think would be the count
    Last edited by Chellobi; 10-02-2017 at 02:46 PM.

  5. #5
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: Conditional Weighted Average with Multiple Variables

    That's an array formula, so to use it successfully put the formula in a cell, select that cell and then press F2 key to select formula then hold down CTRL and SHIFT keys while pressing ENTER. If done correctly you get curly braces like { and } around the formula.

    I also added an alternative "non array" formula to my previous post, you could try that also.

    #DIV/0! is a valid result if there are no rows that meet the criteria

  6. #6
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: Conditional Weighted Average with Multiple Variables

    Quote Originally Posted by Chellobi View Post
    So, It's kind of like the weighted (?) average of
    =AVERAGEIF([(C) Approved], "Pending",[(P) Stories] ) + =AVERAGEIF([(O) Approved], "Pending",[(P) Stories] ) + =AVERAGEIF([(O) Approved], "*Divisional*",[(P) Stories] )
    So if ([(C) Approved]="Pending" then will that row be included irrespective of the [(O) Approved] value?

  7. #7
    Registered User
    Join Date
    10-02-2017
    Location
    Toronto
    MS-Off Ver
    2016
    Posts
    10

    Re: Conditional Weighted Average with Multiple Variables

    Quote Originally Posted by daddylonglegs View Post
    So if ([(C) Approved]="Pending" then will that row be included irrespective of the [(O) Approved] value?
    Yes. Essentially, average for when [(C) Approved] is "Pending", or [(O) Approved] is "Pending" OR "*Divisional*"

    Also, I edited my previous post as well to add:

    So, It's kind of like the weighted (?) average of
    =AVERAGEIF([(C) Approved], "Pending",[(P) Stories] ) + =AVERAGEIF([(O) Approved], "Pending",[(P) Stories] ) + =AVERAGEIF([(O) Approved], "*Divisional*",[(P) Stories] )

    So the weights, I think, come from the fact that each group has a different count... the weight I think would be the count

    (Thanks so much btw!)

  8. #8
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: Conditional Weighted Average with Multiple Variables

    OK, amending my previous suggestion you can try this array formula

    =AVERAGE(IF((Master[(C) Approved]="Pending")+(Master[(O) Approved]="Pending")+ISNUMBER(SEARCH("Divisional",Master[(O) Approved])),Master[(P) Storeys]))

    Confirm with CTRL+SHIFT+ENTER

    That will average all rows where any of the 3 conditions apply

    Does that work for you?

  9. #9
    Registered User
    Join Date
    10-02-2017
    Location
    Toronto
    MS-Off Ver
    2016
    Posts
    10

    Re: Conditional Weighted Average with Multiple Variables

    Quote Originally Posted by daddylonglegs View Post
    OK, amending my previous suggestion you can try this array formula

    =AVERAGE(IF((Master[(C) Approved]="Pending")+(Master[(O) Approved]="Pending")+ISNUMBER(SEARCH("Divisional",Master[(O) Approved])),Master[(P) Storeys]))

    Confirm with CTRL+SHIFT+ENTER

    That will average all rows where any of the 3 conditions apply

    Does that work for you?
    It totally does, wow, thanks!

    Now onto problem number 2...

    I need the same average for Master[(P) Storeys] where

    Master[OMB Approved], "Yes", AND Master[(C) Approved], "<>Yes, via settlement"

    I modified the formula you sent, and made this... is it correct?

    =AVERAGE(IF((Master[(C) Approved]= "<>Yes, via settlement")+(Master[OMB Approved]="Yes"),Master[(P) Storeys]))

  10. #10
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: Conditional Weighted Average with Multiple Variables

    That's close but the + in the previous formula works like "OR" - for "AND" you need *........and the <> needs to be outside the quotes in this type of formula

    =AVERAGE(IF((Master[(C) Approved]<>"Yes, via settlement")*(Master[OMB Approved]="Yes"),Master[(P) Storeys]))

  11. #11
    Registered User
    Join Date
    10-02-2017
    Location
    Toronto
    MS-Off Ver
    2016
    Posts
    10

    Re: Conditional Weighted Average with Multiple Variables

    Thanks,

    Final problem:


    Averaging for..

    (Master[(C) Approved]<>"Yes, via settlement")*(Master[OMB Approved]="Yes") OR
    (Master[(C) Approved]="Yes, via settlement")*(Master[OMB Approved]="Yes") OR
    Master[OMB Approved], "Yes, pending conditions" OR
    Master[OMB Approved], "Withdrawn" OR
    Master[OMB Approved], "Unclear*"

  12. #12
    Registered User
    Join Date
    10-02-2017
    Location
    Toronto
    MS-Off Ver
    2016
    Posts
    10

    Re: Conditional Weighted Average with Multiple Variables

    I can calculate this way as well... if too much hassle to put into one formula. otherway.png

  13. #13
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: Conditional Weighted Average with Multiple Variables

    You can do that like this:

    =AVERAGE(IF((Master[(C) Approved]<>"Yes, via settlement")*(Master[OMB Approved]="Yes")+(Master[(C) Approved]="Yes, via settlement")*(Master[OMB Approved]="Yes")+(Master[OMB Approved]="Yes, pending conditions")+(Master[OMB Approved]="Withdrawn")+(LEFT(Master[OMB Approved],7)="Unclear"),Master[(P) Storeys]))

  14. #14
    Registered User
    Join Date
    10-02-2017
    Location
    Toronto
    MS-Off Ver
    2016
    Posts
    10

    Re: Conditional Weighted Average with Multiple Variables

    Quote Originally Posted by daddylonglegs View Post
    You can do that like this:

    =AVERAGE(IF((Master[(C) Approved]<>"Yes, via settlement")*(Master[OMB Approved]="Yes")+(Master[(C) Approved]="Yes, via settlement")*(Master[OMB Approved]="Yes")+(Master[OMB Approved]="Yes, pending conditions")+(Master[OMB Approved]="Withdrawn")+(LEFT(Master[OMB Approved],7)="Unclear"),Master[(P) Storeys]))
    Thanks.

    I did all this with SUMIFS for other sets, and it's so much easier... AVERAGEIF brought on a whole set of problems.

    ex. to assess by number of Units applied for in 2007 I used the following:

    =SUMIFS(Master[(P) Units],Master[(P) Hearing Date],">=1/1/2007",Master[(P) Hearing Date],"<=12/31/2007") repeated for 10 years (2007 to 2016).

    I now need to convert the following formulas to Averageif

    1. =SUMIFS(Master[(P) Storeys],Master[(P) Hearing Date],">=1/1/2007",Master[(P) Hearing Date],"<=12/31/2007", Master[(C) Approved], "Pending")
    3 conditions, 3 columns: start/end date and Master[(C) Approved]

    Had two other sets I needed help for.. but I'll refrain from going that deep.. Likely unnecessary.

    Going to try and figure this out tomorrow.. Work day's ended and I have class to go to.

    Thanks so much daddylonglegs for your help
    Last edited by Chellobi; 10-02-2017 at 05:27 PM.

  15. #15
    Registered User
    Join Date
    10-02-2017
    Location
    Toronto
    MS-Off Ver
    2016
    Posts
    10

    Re: Conditional Weighted Average with Multiple Variables

    Tried figuring it out.. to difficult for me.

    Pretty disappointed, as I tried hiring someone on Upwork to help me finish the set of averaging calculations.

    Any suggestions on how I could accomplish the following?

    ‘= Average Master[(P) Storeys] where Master[(P) Hearing Date ] > January 1, 2007 and < December 31, 2007, and (Master[(C) Approved], "Pending" or Master[OMB Approved], "Pending" or Master[OMB Approved], "*Divisional*")

    ‘= Average Master[(P) Storeys] where Master[(P) Hearing Date ] > January 1, 2007 and < December 31, 2007, and (Master[(C) Approved], "Pending"

    ‘= Average Master[(P) Storeys] where Master[(P) Hearing Date ] > January 1, 2007 and < December 31, 2007, and Master[(OZ) Storeys ] > 0 and Master[(F Storeys ] > 0 , and (Master[(C) Approved], "Pending"

    ‘= Average Master[(P) Storeys] where Master[(P) Hearing Date ] > January 1, 2007 and < December 31, 2007, and (Master[(C) Approved]={"Yes","Yes, partially"}))

    ‘= Average Master[(P) Storeys] where Master[(P) Hearing Date ] > January 1, 2007 and < December 31, 2007, and Master [(F Storeys ] > 0 , and (Master[(C) Approved]={"Yes","Yes, partially"}))

    ‘= Average Master[(P) Storeys] where Master[(P) Hearing Date ] > January 1, 2007 and < December 31, 2007, and Master[(OZ) Storeys ] > 0 and Master[(F Storeys ] > 0 , and (Master[(C) Approved]={"Yes","Yes, partially"}))

    ‘= Average Master[(P) Storeys] where Master[(P) Hearing Date ] > January 1, 2007 and < December 31, 2007, and (((Master[OMB Approved], "Yes, pending conditions") OR ((Master[OMB Approved]="Yes") and ((Master[(C) Approved]<>"Yes, via settlement") OR (Master[(C) Approved]="Yes, via settlement"))))

    ‘= Average Master[(P) Storeys] where Master[(P) Hearing Date ] > January 1, 2007 and < December 31, 2007, and Master[(F Storeys ] > 0 , and (((Master[OMB Approved], "Yes, pending conditions") OR ((Master[OMB Approved]="Yes") and ((Master[(C) Approved]<>"Yes, via settlement") OR (Master[(C) Approved]="Yes, via settlement"))))

    ‘=Average Master[(P) Storeys] where Master[(P) Hearing Date ] > January 1, 2007 and < December 31, 2007, and Master[(OZ) Storeys ] > 0 and Master[(F Storeys ] > 0 , and (((Master[OMB Approved], "Yes, pending conditions") OR ((Master[OMB Approved]="Yes") and ((Master[(C) Approved]<>"Yes, via settlement") OR (Master[(C) Approved]="Yes, via settlement"))))

  16. #16
    Registered User
    Join Date
    10-02-2017
    Location
    Toronto
    MS-Off Ver
    2016
    Posts
    10

    Re: Conditional Weighted Average with Multiple Variables

    Update: All problems solved with Pivot tables

+ 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. Conditional weighted average
    By bdavila in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 08-30-2017, 01:58 PM
  2. [SOLVED] Want to make weighted average formula conditional
    By Butcher1 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 03-10-2016, 09:23 AM
  3. Weighted Average accounting for 2 variables??
    By dz6kb4 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 11-19-2013, 08:35 AM
  4. Weighted Average IF (sumproduct conditional)
    By Leopold2000 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-16-2013, 03:27 PM
  5. Conditional weighted average ignoring #N/A values
    By syoung27 in forum Excel General
    Replies: 4
    Last Post: 02-22-2012, 10:48 AM
  6. Weighted Average with multiple variables
    By bigtoad in forum Excel General
    Replies: 4
    Last Post: 02-27-2011, 04:07 PM
  7. Conditional weighted average
    By saturnexcel in forum Excel General
    Replies: 8
    Last Post: 04-20-2009, 04:06 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