+ Reply to Thread
Results 1 to 5 of 5
  1. #1
    Registered User
    Join Date
    07-08-2008
    Location
    Durham, NC
    Posts
    10

    Help with IF(AND(AVERAGE...

    Hello,

    You have been incredibly helpful in the past. Can anyone find what is wrong with the function I am trying to use:

    =IF(AND(Sorted!$B$2:Sorted!$B$38377=Pluses!A2,Sorted!$F$2:Sorted!$F$38377=Pluses!B2,Sorted!$L$2:Sort ed!$L$38377=Pluses!C2,Sorted!$M$2:Sorted!$M$38377=1,Sorted!$E$2:Sorted!$E$38377="plus",Sorted!$I$2:S orted!$I$38377="no"),AVERAGE(Sorted!$N$2:Sorted!$N$38377),"X")

    I know that this is an array formula, and I have been using Shift+Ctrl+Enter. The formula itself does not cause an error, but I end up with the "X" in the cell, and that's not correct, because there are values that match all of these statements.

    I am using two sheets called "Sorted" and "Pluses."

    I am trying to do the following:

    IF all of the following are true:
    - the value in SortedColumnB for a particular row equals PlusesA2
    - the value in SortedColumnF for a particular row equals PlusesB2
    - the value in SortedColumnL for a particular row equals PlusesC2
    - the value in SortedColumnM for a particular row equals 1
    - the value in SortedColumnE for a particular row equals 'plus'
    - the value in SortedColumnI for a particular row equals 'no'

    THEN:
    average all of the values in SortedColumnN for which cells B, F, L, M, E, and I for a particular row meet all of specified criteria

    Thanks in advance!

  2. #2
    Forum Moderator daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2007
    Posts
    9,507

    Re: Help with IF(AND(AVERAGE...

    Try like this

    =AVERAGE(IF((Sorted!$B$2:$B$38377=Pluses!A2)*(Sorted!$F$2:$F$38377=Pluses!B2)*(Sorted!$L$2:$L$38377= Pluses!C2)*( Sorted!$M$2:$M$38377=1)*(Sorted!$E$2:$E$38377="plus")*(Sorted!$I$2:$I$38377="no"), Sorted!$N$2:$N$38377))

    confirmed with CTRL+SHIFT+ENTER

  3. #3
    Forum Moderator DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Suffolk, UK
    MS-Off Ver
    2002, 2007 & 2010
    Posts
    21,379

    Re: Help with IF(AND(AVERAGE...

    Assuming you're running a version pre 2007:

    Code:
    =AVERAGE(IF((Sorted!$B$2:$B$38377=Pluses!A2)*(Sorted!$F$2:$F$38377=Pluses!B2)*(Sorted!$L$2:$L$38377=Pluses!C2)*(Sorted!$M$2:$M$38377=1)*(Sorted!$E$2:$E$38377="plus")*(Sorted!$I$2:$I$38377="no"),Sorted!$N$2:$N$38377))
    committed with CTRL + SHIFT + ENTER
    (edit: the above is a repetition of dll's formula)

    If running XL2007 you should make use of the AVERAGEIFS function.

    NOTE: the above array will be a poor performer given magnitude of ranges... pending volume of arrays to be put into use it might also be worth considering a Pivot Table perhaps ?

  4. #4
    Registered User
    Join Date
    07-08-2008
    Location
    Durham, NC
    Posts
    10

    Re: Help with IF(AND(AVERAGE...

    Thanks for your help. I tried that formula, and it's giving me a Div/0 error. I played around with it for a bit and can't find out why.

    I've never used pivot tables before. I think I might try now. Thanks.

  5. #5
    Forum Moderator DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Suffolk, UK
    MS-Off Ver
    2002, 2007 & 2010
    Posts
    21,379

    Re: Help with IF(AND(AVERAGE...

    The #DIV/0 would imply you have no rows in your data that meet all of the specified criteria - try removing one test at a time from the formula (remembering to confirm with Ctrl + Shift + Enter each time) so as to see which conditions are met and which are not to help pinpoint the possible underlying issue.
    Last edited by DonkeyOte; 07-27-2009 at 01:47 PM. Reason: reworded...

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.2.0