+ Reply to Thread
Results 1 to 9 of 9

average with multiple criteria including OR

  1. #1
    Registered User
    Join Date
    02-19-2015
    Location
    London
    MS-Off Ver
    2013
    Posts
    9

    Exclamation average with multiple criteria including OR

    Hi all,

    I have a dataset and I'm focusing on two of the columns, Trial and TaskError. I want to calculate the mean TaskError when Trial = 1 and TaskError is either a 1 or a 0. TaskError can also be -99 (as in missing) or -88 (some other criteria).

    I tried AVERAGEIFS but found I couldn't put the OR criteria in.
    Tried AVERAGE(IF((TRIALCELLS = 1)*((TASKERRORCELLS = 1)+(TASKERRORCELLS = 0)), TASKERRORCELLS)) and ctrl+shift+enter to get the curly bracets based on this post (https://www.excelforum.com/excel-for...statement.html) but I got an #N/A error.

    Any help would be much appreciated as this is for around 25 people each with 5 trial types I need to do it for, and this then gets fed into a larger matlab script to do other stuff.

    Thanks!!

  2. #2
    Forum Expert
    Join Date
    03-23-2004
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    7,064

    Re: average with multiple criteria including OR

    Post a sample spreadsheet with expected results, remove any sensitive data, create a mockup example if necessary.
    Use the Go Advanced option at the bottom of the page then scroll down to Manage Attachments as the "paperclip" method does not work on this forum.
    Regards
    Special-K

    Ensure you describe your problem clearly, I have little time available to solve these problems and do not appreciate numerous changes to them.

  3. #3
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: average with multiple criteria including OR

    Hi,

    Perhaps this
    =SUM(SUMIFS(TASKERRORCELLS,TRIALCELLS ,1,TASKERRORCELLS,{0,1}))/SUM(COUNTIFS(TRIALCELLS ,1,TASKERRORCELLS,{0,1}))
    normally entered.
    Don
    Please remember to mark your thread 'Solved' when appropriate.

  4. #4
    Registered User
    Join Date
    02-19-2015
    Location
    London
    MS-Off Ver
    2013
    Posts
    9

    Re: average with multiple criteria including OR

    Hopefully there should be an example attached...
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    02-19-2015
    Location
    London
    MS-Off Ver
    2013
    Posts
    9

    Re: average with multiple criteria including OR

    I tried this within my actual dataset (not the example attached) and got 0 as the answer, but when I entered it in manually I got a different answer. Can I ask what the {} do in the formula?

  6. #6
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,170

    Re: average with multiple criteria including OR

    The {0,1} used in conjunction with the SUM(...) is an OR condition so coercing SUMIF to execute twice, once for 0 and then 1: same for the COUNTIF.

    Works fine on your posted file.

  7. #7
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: average with multiple criteria including OR

    Quote Originally Posted by RAYCHLICKLEY View Post
    I tried this within my actual dataset (not the example attached) and got 0 as the answer, but when I entered it in manually I got a different answer. Can I ask what the {} do in the formula?
    I'm not sure what "entered it in manually" means. If you mean that you worked it out manually, then I'd assume that either you made a mistake, or some of the data is not exactly what it appears to be. Impossible to be sure without the actual data set.

  8. #8
    Registered User
    Join Date
    02-19-2015
    Location
    London
    MS-Off Ver
    2013
    Posts
    9

    Re: average with multiple criteria including OR

    Quote Originally Posted by xlnitwit View Post
    Hi,

    Perhaps this
    =SUM(SUMIFS(TASKERRORCELLS,TRIALCELLS ,1,TASKERRORCELLS,{0,1}))/SUM(COUNTIFS(TRIALCELLS ,1,TASKERRORCELLS,{0,1}))
    normally entered.
    Thanks for this, it does indeed work! My error -- I was trying it on trial type 4 but forgot to alter the formula to reflect that.

    Thanks again!

  9. #9
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,170

    Re: average with multiple criteria including OR

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. 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. [SOLVED] Add if multiple criteria met including some criteria that share a column
    By HelenClark in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 05-02-2017, 11:36 AM
  2. Count which includes multiple columns including multiple criteria
    By Zou in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 04-27-2017, 10:43 AM
  3. Using Multiple Criteria (Including Dates) for a Vlookup
    By PaulMcCudden in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 07-23-2015, 01:16 PM
  4. Replies: 16
    Last Post: 05-25-2015, 08:51 AM
  5. Max, Min, & Std Dev with Multiple Criteria Including a Wild Card
    By rmmohan in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 06-14-2013, 12:45 PM
  6. Looking for last entry using multiple criteria including date
    By ayrmad in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 02-06-2013, 11:36 PM
  7. sumif with multiple criteria (including daterange)
    By TPS Tom in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 11-28-2011, 07:43 AM

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.6.0 RC 1