+ Reply to Thread
Results 1 to 13 of 13

Average(ifs) meeting certain criteria

Hybrid View

B7Des Average(ifs) meeting certain... 07-30-2014, 05:12 AM
samba_ravi Re: Average(ifs) meeting... 07-30-2014, 05:37 AM
B7Des Re: Average(ifs) meeting... 07-30-2014, 06:20 AM
Hawkeye16 Re: Average(ifs) meeting... 07-30-2014, 06:29 AM
B7Des Re: Average(ifs) meeting... 07-30-2014, 06:37 AM
daddylonglegs Re: Average(ifs) meeting... 07-30-2014, 06:41 AM
XOR LX Re: Average(ifs) meeting... 07-30-2014, 06:53 AM
samba_ravi Re: Average(ifs) meeting... 07-30-2014, 07:05 AM
samba_ravi Re: Average(ifs) meeting... 07-30-2014, 07:11 AM
Hawkeye16 Re: Average(ifs) meeting... 07-30-2014, 06:48 AM
daddylonglegs Re: Average(ifs) meeting... 07-30-2014, 07:03 AM
samba_ravi Re: Average(ifs) meeting... 07-30-2014, 06:59 AM
Hawkeye16 Re: Average(ifs) meeting... 07-30-2014, 07:28 AM
  1. #1
    Registered User
    Join Date
    07-30-2014
    Location
    Berlin, Germany
    MS-Off Ver
    2010
    Posts
    7

    Question Average(ifs) meeting certain criteria

    Hello,

    I have some "problems" with averageifs formula.
    Maybe someone can give me some hints/help.
    I have uploaded an exemple sheet with some notes about my "problem"

    Thanks,
    Attached Files Attached Files

  2. #2
    Forum Guru samba_ravi's Avatar
    Join Date
    07-26-2011
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2021
    Posts
    8,941

    Re: Average(ifs) meeting certain criteria

    =SUM(INDEX(((($B$7:$B$25=$B$3)*($C$7:$C$25=$C$3)+($B$7:$B$25=$C$3)*($C$7:$C$25=$B$3))>0)*($F$7:$F$25),0))/SUM(INDEX(((($B$7:$B$25=$B$3)*($C$7:$C$25=$C$3)+($B$7:$B$25=$C$3)*($C$7:$C$25=$B$3))>0)*(1),0))
    Try this formula
    Samba

    Say thanks to those who have helped you by clicking Add Reputation star.

  3. #3
    Registered User
    Join Date
    07-30-2014
    Location
    Berlin, Germany
    MS-Off Ver
    2010
    Posts
    7

    Re: Average(ifs) meeting certain criteria

    Thank's Siva!

    This solve only half of my problem.

    How to calculate only the last 3 value that meet that criteria?

    Thanks,

    Luciano

  4. #4
    Valued Forum Contributor Hawkeye16's Avatar
    Join Date
    02-27-2013
    Location
    Holland
    MS-Off Ver
    ├•┤ Pew Pew
    Posts
    441

    Re: Average(ifs) meeting certain criteria

    See attached. The formula is fairly compact, but is an array formula so if you change it you will need to press Ctrl + Shift + Enter to compute.

    You can change the number of largest by adding/subtracting items from the final array of numbers {1,2,3}.

    For your first question which I didnt see at first you could also use
    =AVERAGE(IF(($B$3&$C$3=$B$7:$B$25&$C$7:$C$25)+($C$3&$B$3=$B$7:$B$25&$C$7:$C$25),$F$7:$F$25))

    Which is also an array formula so needs Ctrl + Shift + Enter
    Attached Files Attached Files
    Last edited by Hawkeye16; 07-30-2014 at 06:36 AM.
    Despite the high cost of living, it remains very popular.

    Don't forget to mark threads SOLVED when you get an answer and rep all the geniouses that helped you today!

  5. #5
    Registered User
    Join Date
    07-30-2014
    Location
    Berlin, Germany
    MS-Off Ver
    2010
    Posts
    7

    Re: Average(ifs) meeting certain criteria

    Thank's Hawkeye16 !

    Siva's formula work how i want. But i need that it that calculate only for last 3 value (for exemple).
    I think it must make this index only for the last 3 values ???
    $B$7:$B$25=$B$3)*($C$7:$C$25=$C$3)
    Like in this post:

    http://www.excelforum.com/excel-gene...-criteria.html

    But with more criteria

    Thanks,
    Last edited by B7Des; 07-30-2014 at 06:42 AM.

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

    Re: Average(ifs) meeting certain criteria

    To get an average for the criteria satisfied in either column you can use this "array formula"

    =AVERAGE(IF((B7:B25=B3)*(C7:C25=C3)+(B7:B25=C3)*(C7:C25=B3),F7:F25))

    confirmed with CTRL+SHIFT+ENTER

    and for only the last 3 satisfying those criteria (assuming there will always be at least 3) you can use this array formula

    =AVERAGE(IF(ROW(F7:F25)>=LARGE(IF((B7:B25=B3)*(C7:C25=C3)+(B7:B25=C3)*(C7:C25=B3),ROW(F7:F25)),3),IF((B7:B25=B3)*(C7:C25=C3)+(B7:B25=C3)*(C7:C25=B3),F7:F25)))

    change the bolded 3 for last n
    Audere est facere

  7. #7
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Average(ifs) meeting certain criteria

    (self-deleted)
    Last edited by XOR LX; 07-30-2014 at 06:56 AM.
    Click * below if this answer helped

    Advanced Excel Techniques: http://excelxor.com/

  8. #8
    Forum Guru samba_ravi's Avatar
    Join Date
    07-26-2011
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2021
    Posts
    8,941

    Re: Average(ifs) meeting certain criteria

    Mr Hawkeye16 your formula will not work if we remove any one of last 3 rows

  9. #9
    Forum Guru samba_ravi's Avatar
    Join Date
    07-26-2011
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2021
    Posts
    8,941

    Re: Average(ifs) meeting certain criteria

    =SUM(INDEX((ROW($F$7:$F$24)>=LARGE(INDEX(((($B$7:$B$24=$B$3)*($C$7:$C$24=$C$3)+($B$7:$B$24=$C$3)*($C$7:$C$24=$B$3))>0)*ROW($F$7:$F$24),0),3))*($F$7:$F$24),0))/MIN(SUM(INDEX((ROW($F$7:$F$24)>=LARGE(INDEX(((($B$7:$B$24=$B$3)*($C$7:$C$24=$C$3)+($B$7:$B$24=$C$3)*($C$7:$C$24=$B$3))>0)*ROW($F$7:$F$24),0),3))*1,0)),3)
    This one also will work

  10. #10
    Valued Forum Contributor Hawkeye16's Avatar
    Join Date
    02-27-2013
    Location
    Holland
    MS-Off Ver
    ├•┤ Pew Pew
    Posts
    441

    Re: Average(ifs) meeting certain criteria

    Ah, the last 3. I for some reason thought you meant the largest 3, which is what my attachment answered.

    DaddyLongLegs - your formula actually can shorten to this

    =AVERAGE(IF(ROW(F7:F25)>=LARGE(IF((B7:B25=B3)*(C7:C25=C3)+(B7:B25=C3)*(C7:C25=B3),ROW(F7:F25)),3),F7:F25))
    Last edited by Hawkeye16; 07-30-2014 at 06:52 AM.

  11. #11
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,721

    Re: Average(ifs) meeting certain criteria

    Quote Originally Posted by Hawkeye16 View Post
    DaddyLongLegs - your formula actually can shorten to this

    =AVERAGE(IF(ROW(F7:F25)>=LARGE(IF((B7:B25=B3)*(C7:C25=C3)+(B7:B25=C3)*(C7:C25=B3),ROW(F7:F25)),3),F7:F25))
    No, I don't think so

    That works for the specific example given, but what if you change last 3 to last 4? Your version will include rows that don't meet the criteria and you'd get a result of 1.53 rather than the required 5.75

  12. #12
    Forum Guru samba_ravi's Avatar
    Join Date
    07-26-2011
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2021
    Posts
    8,941

    Re: Average(ifs) meeting certain criteria

    =SUM(INDEX(((($B$7:$B$25=$B$3)*($C$7:$C$25=$C$3)+($B$7:$B$25=$C$3)*($C$7:$C$25=$B$3))>0)*(ROW($F$7:$F$25)>=LARGE(INDEX(((($B$7:$B$25=$B$3)*($C$7:$C$25=$C$3)+($B$7:$B$25=$C$3)*($C$7:$C$25=$B$3))>0)*ROW($F$7:$F$25),0),3))*(F7:F25),0))/MIN(SUM(INDEX(((($B$7:$B$25=$B$3)*($C$7:$C$25=$C$3)+($B$7:$B$25=$C$3)*($C$7:$C$25=$B$3))>0)*(ROW($F$7:$F$25)>=LARGE(INDEX(((($B$7:$B$25=$B$3)*($C$7:$C$25=$C$3)+($B$7:$B$25=$C$3)*($C$7:$C$25=$B$3))>0)*ROW($F$7:$F$25),0),3))*1,0)),3)
    Try this formula

  13. #13
    Valued Forum Contributor Hawkeye16's Avatar
    Join Date
    02-27-2013
    Location
    Holland
    MS-Off Ver
    ├•┤ Pew Pew
    Posts
    441

    Re: Average(ifs) meeting certain criteria

    I see, doesn't work if the number is greater than the actual matches it finds. I stand corrected.

+ 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. [SOLVED] Average of numbers within a range meeting certain criteria
    By opal23k in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 12-13-2010, 06:06 PM
  2. Excel 2007 : average last 5 values meeting certain criteria
    By jrbdotcom31 in forum Excel General
    Replies: 4
    Last Post: 05-15-2010, 11:47 PM
  3. Average of numbers within a range meeting certain criteria
    By opal23k in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 06:05 PM
  4. [SOLVED] Average of numbers within a range meeting certain criteria
    By opal23k in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 03:05 AM
  5. [SOLVED] Average of numbers within a range meeting certain criteria
    By opal23k in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 01:05 AM

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