+ Reply to Thread
Results 1 to 17 of 17

Aggregate Function based on an If Statement???

  1. #1
    Registered User
    Join Date
    03-04-2014
    Location
    Portsmouth, England
    MS-Off Ver
    Excel 2010
    Posts
    21

    Aggregate Function based on an If Statement???

    Hi

    I'm trying to work out the avergare of column AE which contains some #NA's but I only want the average if P matches a specifc criteria, in this case "T". I have tried various ways in order to get this but I'm failing,

    AGGREGATE(IF(P2:P134,"t"),1,6,AE2:AE134) Result = #VALUE!

    IF(P2:P134,"t",AGGREGATE(1,6,AE2:AE134)) Result = #VALUE!

    IF(AGGREGATE(1,6,AE2:AE134),P2:P134,"T") Result = F

    Can anyone help PLEASE!!!

  2. #2
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Aggregate Function based on an If Statement???

    Have you tried this one?

    AverageIF(P2:P134,"t")
    Notice my main language is not English.

    I appreciate it, if you reply on my solution.

    If you are satisfied with the solution, please mark the question solved.

    You can add reputation by clicking on the star * add reputation.

  3. #3
    Registered User
    Join Date
    03-04-2014
    Location
    Portsmouth, England
    MS-Off Ver
    Excel 2010
    Posts
    21

    Re: Aggregate Function based on an If Statement???

    Hi

    Column P only contains one of the following, T, F, WB, NWB or M. AverageIF(P2:P134,"t") will not work because I haven't tied in any of the actual values which are in AE?

    Any other suggestions?

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

    Re: Aggregate Function based on an If Statement???

    Hi,

    =AVERAGEIF(P2:P134,"t",AE2:AE134)

    Regards
    Click * below if this answer helped

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

  5. #5
    Registered User
    Join Date
    03-04-2014
    Location
    Portsmouth, England
    MS-Off Ver
    Excel 2010
    Posts
    21

    Re: Aggregate Function based on an If Statement???

    Thanks but this doesn't work either due to the #NA's within AE. I have tried to use ISNUMBER as well but wasn't successful...

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

    Re: Aggregate Function based on an If Statement???

    Apologies - didn't read your question properly.

    You will need an array formula**:

    =AVERAGE(IF(ISNUMBER(AE2:AE134),IF(P2:P134="t",AE2:AE134)))

    Regards


    **Array formulas are not entered in the same way as 'standard' formulas. Instead of pressing just ENTER, you first hold down CTRL and SHIFT, and only then press ENTER. If you've done it correctly, you'll notice Excel puts curly brackets {} around the formula (though do not attempt to manually insert these yourself).

  7. #7
    Registered User
    Join Date
    03-04-2014
    Location
    Portsmouth, England
    MS-Off Ver
    Excel 2010
    Posts
    21

    Re: Aggregate Function based on an If Statement???

    Thank you, thank you, thank you - it worked!!!

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

    Re: Aggregate Function based on an If Statement???

    You're welcome!

  9. #9
    Valued Forum Contributor Saarang84's Avatar
    Join Date
    02-19-2009
    Location
    Chennai, India
    MS-Off Ver
    XL 2003 to 2010
    Posts
    812

    Re: Aggregate Function based on an If Statement???

    Hi,

    Can u post a workbook with sample data (remove sensitive information, but not the #N/A's) so that we can work out a solution?
    If my assistance has helped, there is a reputation icon * on the left hand corner below the post - you can show your appreciation to the user who has helped in resolving your requirement.

    If your requirement has been solved please mark your thread as Solved.
    In the menu bar above the very first post, select Thread Tools, then select "Mark this thread as Solved".

    Kindly use [FORMULA] or [CODE] tags when posting your code.

    Regards,
    Sarang

  10. #10
    Registered User
    Join Date
    03-04-2014
    Location
    Portsmouth, England
    MS-Off Ver
    Excel 2010
    Posts
    21

    Re: Aggregate Function based on an If Statement???

    Hi Sarang

    Thank you for your assistance but XOR LX has resolved the problem for me.

    Thanks

  11. #11
    Registered User
    Join Date
    03-04-2014
    Location
    Portsmouth, England
    MS-Off Ver
    Excel 2010
    Posts
    21

    Re: Aggregate Function based on an If Statement???

    Hi Sarang

    Thank you for your assistance but XOR LX has resolved the problem for me.

    Thanks

  12. #12
    Valued Forum Contributor Saarang84's Avatar
    Join Date
    02-19-2009
    Location
    Chennai, India
    MS-Off Ver
    XL 2003 to 2010
    Posts
    812

    Re: Aggregate Function based on an If Statement???

    Try,
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Extend worksheet ranges as necessary

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

    Re: Aggregate Function based on an If Statement???

    Quote Originally Posted by Saarang84 View Post
    Try,
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Extend worksheet ranges as necessary
    Have you tested this yourself? What results did you get?

    Are you trying to array-enter an AVERAGEIF formula?

    Do you know that the ranges in this formula must be actual worksheet references, and not the results of formulas?

    Regards

  14. #14
    Valued Forum Contributor Saarang84's Avatar
    Join Date
    02-19-2009
    Location
    Chennai, India
    MS-Off Ver
    XL 2003 to 2010
    Posts
    812

    Re: Aggregate Function based on an If Statement???

    Hi XOR,

    This does work well.. I tested it before posting it here. Refer workbook attached. However, this formula doesn't seem to work when paste in the row where #N/A is found. Wonder why is it so? Do you know the reason?

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

    Re: Aggregate Function based on an If Statement???

    Quote Originally Posted by Saarang84 View Post
    Hi XOR,

    This does work well.. I tested it before posting it here. Refer workbook attached. However, this formula doesn't seem to work when paste in the row where #N/A is found. Wonder why is it so? Do you know the reason?
    Go through your formula with the Evaluate Formula tool. See what happens when it gets to:

    IF(ISNUMBER($A$2:$A$11)

    Only the first element of that range (A2) is passed to the function, since nothing is coercing it to operate on the entire array.

    Regards

  16. #16
    Valued Forum Contributor Saarang84's Avatar
    Join Date
    02-19-2009
    Location
    Chennai, India
    MS-Off Ver
    XL 2003 to 2010
    Posts
    812

    Re: Aggregate Function based on an If Statement???

    Hi XOR,

    After evaluating the entire formula, I get this...

    =AVERAGEIF({"F";"T";"WB";"NWB";0;0;"F";"T";"WB";"NWB"},"WB",{10;32;35;21;0;0;30;28;15;19})

    But it does return the correct average value.. How does this work?

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

    Re: Aggregate Function based on an If Statement???

    You haven't used the Evaluate Formula tool. You've pressed F9 repeatedly in the formula bar, which is a dangerous thing to do if you're not fully aware of how this feature operates, since there arrays are "evaluated" even if the actual formula in question would not otherwise evaluate them as such, as in your case.

    Regards

+ 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. Aggregate Function
    By nav505 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 06-04-2013, 03:20 AM
  2. Problem with Aggregate Function ADO SQL
    By Kyle123 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-10-2010, 07:44 AM
  3. how to calculate aggregate numbers based on a certain criteria
    By Sheki in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 07-06-2007, 01:47 AM
  4. Aggregate function
    By stefantem in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-19-2006, 04:47 AM
  5. SQL - As part of an aggregate function ERROR
    By dave k in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-07-2005, 12: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