+ Reply to Thread
Results 1 to 9 of 9

Need 'criteria' within AVERAGEIFS formula to automatically increase when dragging down

  1. #1
    Registered User
    Join Date
    01-07-2014
    Location
    United Kingdom
    MS-Off Ver
    Excel 2007
    Posts
    2

    Need 'criteria' within AVERAGEIFS formula to automatically increase when dragging down

    Hi,

    Using AVERAGEIFS formula I am trying to find an average heart rate for 10 second chunks. The HR raw data is sporadic and therefore I do not have 10 data points per 10 seconds consistently. This is the formula as it stands;

    =AVERAGEIFS($B$3:$B$14580,$A$3:$A$14580,">00:00:01",$A$3:$A$14580,"<00:00:10")

    This provides me with the average HR for the first 10 sec.

    I know need to copy this formula with the 'criteria' section of the formula (">00:00:01" and "<00:00:10") increasing by 10 seconds each time, therefore the next formula would read;

    =AVERAGEIFS($B$3:$B$14580,$A$3:$A$14580,">00:00:11",$A$3:$A$14580,"<00:00:20")

    I have 24 files each of approximately 5-6 hours therefore cannot manually completely this!!

    Is it possible to setup the formula to increase by 10 seconds each time?

    I have attached the spreadsheet should it be of assistance.

    Many thanks in advance!
    Last edited by javboy800; 01-07-2014 at 10:42 AM.

  2. #2
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Need 'criteria' within AVERAGEIFS formula to automatically increase when dragging down

    =AVERAGEIFS($B$3:$B$14580,$A$3:$A$14580,">00:00:01",$A$3:$A$14580,"<00:00:10")
    =AVERAGEIFS($B$3:$B$14580,$A$3:$A$14580,">00:00:11",$A$3:$A$14580,"<00:00:20")

    before we go on what happens between 00:00:10 and 00:00:11 those formulas discount both of those
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  3. #3
    Forum Expert Ace_XL's Avatar
    Join Date
    06-04-2012
    Location
    UAE
    MS-Off Ver
    2016
    Posts
    6,074

    Re: Need 'criteria' within AVERAGEIFS formula to automatically increase when dragging down

    Try in first cell

    =AVERAGEIFS($B$3:$B$14580,$A$3:$A$14580,">="&((ROW(A1)-1)*10+1)/24/60/60,$A$3:$A$14580,"<="&((ROW(A1)-1)*10+10)/24/60/60)

    Copy down
    Life's a spreadsheet, Excel!
    Say thanks, Click *

  4. #4
    Forum Expert
    Join Date
    02-19-2013
    Location
    India
    MS-Off Ver
    07/16
    Posts
    2,386

    Re: Need 'criteria' within AVERAGEIFS formula to automatically increase when dragging down

    Hello Javboy ! Welcome to the forum try this in d4

    =AVERAGEIFS($B$3:$B$14580,$A$3:$A$14580,">00:00:"&(((ROW(A1)-ROW($A$1)))*10)+1,$A$3:$A$14580,"<00:00:"&(((ROW(A2)-ROW($A$1)))*10))
    and drag down
    Last edited by hemesh; 01-07-2014 at 09:45 AM.
    -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    WANT TO SAY THANKS, HIT ADD REPUTATION (*) AT THE BOTTOM LEFT CORNER OF THE POST

    More we learn about excel, more it shows us, how less we know about it.

    for chemistry
    https://www.youtube.com/c/chemistrybyshivaansh

  5. #5
    Valued Forum Contributor
    Join Date
    10-06-2008
    Location
    Norway
    MS-Off Ver
    2010
    Posts
    365

    Re: Need 'criteria' within AVERAGEIFS formula to automatically increase when dragging down

    Hi, try in D4
    =AVERAGEIFS($B$3:$B$14580,$A$3:$A$14580,">00:00:"&E4,$A$3:$A$14580,"<00:00:"&F4)

  6. #6
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Need 'criteria' within AVERAGEIFS formula to automatically increase when dragging down

    NeverMind, beaten to it.

  7. #7
    Registered User
    Join Date
    01-07-2014
    Location
    United Kingdom
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: Need 'criteria' within AVERAGEIFS formula to automatically increase when dragging down

    Thank you so much!! It works!!!

    Interestingly, estige did not work (or at least I could not get it working!) but hemesh and Ace_XL did!

    I am curious as to what the formula actually means now! i.e. i can see that /24/60/60 is converting the time format into a 'real' number, but what

    &((ROW(A1)-1)*10+1)/

    means I have no idea!

    Thanks again! Really appreciate the help!

  8. #8
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Need 'criteria' within AVERAGEIFS formula to automatically increase when dragging down

    did no one bother to wonder why the rages are not inclusive

  9. #9
    Valued Forum Contributor
    Join Date
    10-06-2008
    Location
    Norway
    MS-Off Ver
    2010
    Posts
    365

    Re: Need 'criteria' within AVERAGEIFS formula to automatically increase when dragging down

    To martinwilson.
    I saw your observation a bit late. But it seems the function return the correct average anyway? I'm not sure why.

    All these give the same result as far as I can see:
    =AVERAGEIFS($B$3:$B$14580,$A$3:$A$14580,">00:00:"&E4,$A$3:$A$14580,"<00:00:"&F4)
    =AVERAGEIFS($B$3:$B$14580,$A$3:$A$14580,">=00:00:"&E4,$A$3:$A$14580,"<=00:00:"&F4)
    =AVERAGEIFS($B$3:$B$14580,$A$3:$A$14580,">="&"00:00:"&E4,$A$3:$A$14580,"<="&00:00:"&F4)

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

    Re: Need 'criteria' within AVERAGEIFS formula to automatically increase when dragging down

    Quote Originally Posted by estige View Post
    All these give the same result as far as I can see:
    =AVERAGEIFS($B$3:$B$14580,$A$3:$A$14580,">00:00:"&E4,$A$3:$A$14580,"<00:00:"&F4)
    =AVERAGEIFS($B$3:$B$14580,$A$3:$A$14580,">=00:00:"&E4,$A$3:$A$14580,"<=00:00:"&F4)
    =AVERAGEIFS($B$3:$B$14580,$A$3:$A$14580,">="&"00:00:"&E4,$A$3:$A$14580,"<="&00:00:"&F4)
    I think you do get different results for some of those formulas (101 to 110 on row 14 for example).....but there is a problem because actually none of them are giving correct results in all cases because some of the rows aren't included by any of those, e.g. between 11 and 20, assuming that should be inclusive (because the previous range ends at 10 and the next starts at 21) the result should be the same as

    =AVERAGE(B8:B15) = 118.125

    ....but all of those formulas give the result as 117

    That's because of rounding errors, so even using >= and <= here doesn't entirely work. You need a formula that will round to the nearest second so that no rows are excluded. You can do that with this "array" formula

    =AVERAGE(IF(TEXT(A$3:A$14580,"[s]")+0>=E4,IF(TEXT(A$3:A$14580,"[s]")+0<=F4,B$3:B$14580)))

    confirmed woth CTRL+SHIFT+ENTER

    ....or with ROUND like this

    =AVERAGE(IF(ROUND(A$3:A$14580*86400,0)>=E4,IF(ROUND(A$3:A$14580*86400,0)<=F4,B$3:B$14580)))

    If you want to stay with a non-array AVERAGEIFS use a helper column, e.g. in C3 use this formula copied down

    =ROUND(A3*86400,0)

    and then you can use AVERAGEIFS like this

    =AVERAGEIFS(B:B,C:C,">="&E4,C:C,"<="&F4)

    .....On top of that, none of those formulas handle 10000+ seconds (see row 1003 onwards) whereas my suggestions have no problem with that.

    To check that all rows are covered change that last AVERAGEIFS to COUNTIFS, i.e.

    =COUNTIFS(C:C,">="&E4,C:C,"<="&F4)

    copy that down and sum the results and you get 14578, i.e. the number of rows of data - that proves that all the rows are being included in the COUNTIFS (and by extension the AVERAGEIFS)
    Last edited by daddylonglegs; 01-07-2014 at 11:10 AM.
    Audere est facere

+ 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] Problem with AVERAGEIFS formula when data has missing criteria
    By mcfarcry in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 12-05-2013, 05:00 PM
  2. Averageifs formula with criteria as formulas
    By KCD in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 08-07-2013, 05:34 PM
  3. [SOLVED] How to change reference area automatically by dragging Index Match Formula down
    By Nuada in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 06-20-2013, 01:19 PM
  4. Increase formula data by 1 when dragging down.
    By tecra134 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-15-2011, 01:57 AM
  5. Increase cell range by 2 when dragging down
    By NBC_Brian in forum Excel General
    Replies: 7
    Last Post: 06-03-2011, 03:29 PM

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