+ Reply to Thread
Results 1 to 11 of 11

Average of every nth row

Hybrid View

  1. #1
    Registered User
    Join Date
    08-15-2016
    Location
    London
    MS-Off Ver
    2007
    Posts
    6

    Average of every nth row

    Hi,

    I have a dataset madeup of 6 columns.

    The dataset has been filled where under each heading there are 25 entries representing different sampling timers. Under the 25th entry is another row of the same column headings.

    I want to create a summary of the dataset where each entry is the average of average 27th cell. i.e. average of value at sample time 1 etc...

    I have tried the following formula =AVERAGE(IF(MOD(ROW(A2:A1562),27)=0,A2:A1562))
    adapted from http://www.atlaspm.com/toms-tutorial...very-nth-cell/

    But i am getting the value 0 out every time?

    Does anybody have an idea of where i am going wrong here?

    Kind Regards,

    Gray

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

    Re: Average of every nth row

    Can you attach a sample book?

    Maybe the values in column A are not real numbers, but numbers stored as text?

    Also important, the formula needs to be enterd as an array by pressing CTRL + SHIFT + ENTER

  3. #3
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,956

    Re: Average of every nth row

    That formula looks like it might work if entered as an array formula. Select the formula bar and instead of just pressing Enter, Press CTRL-SHIFT-ENTER and it should appear to have curly braces {} around the formula when you do that.

    P.S. This article should make you familiar with the concept of how array formulas work: http://www.utteraccess.com/wiki/inde...Array_Formulas.
    Basically Array Formulas work on ranges of cells instead of individual cells and you can sometimes limit which cells within the range the formula looks at by putting if statements around the range.

    In this case the formula looks at the range A2:A1562 but only pays attention to those where MOD(ROW(A2:A1562),27)=0
    Last edited by dflak; 08-15-2016 at 04:04 PM. Reason: Add PS
    One spreadsheet to rule them all. One spreadsheet to find them. One spreadsheet to bring them all and at corporate, bind them.

    A picture is worth a thousand words, but a sample spreadsheet is more likely to be worked on.

  4. #4
    Registered User
    Join Date
    08-15-2016
    Location
    London
    MS-Off Ver
    2007
    Posts
    6

    Re: Average of every nth row

    Hi,

    Cheers, entering it as an array is making the formula 'work'.

    Problem is i think the formula is not correct for my purpose.
    Formula seems to be skipping some values.


    samplebook.xlsx



    G

  5. #5
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Average of every nth row

    I think that this is what you need.

    =AVERAGE(IF(MOD(ROW(A2:A104)-2,26)=0,A2:A104))

    -2, because that is the row with the first record to average.

    26 because you have 26 rows per table (25 rows of data plus header).

    Or you could do it this way instead

    =AVERAGE(IF(MOD(ROW(A2:A104),26)=2,A2:A104))

    Either way, 2 and 26 are the relevant factors.
    Last edited by jason.b75; 08-16-2016 at 07:44 AM.

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

    Re: Average of every nth row

    Try

    =AVERAGEIF(A$1:A$79,"?*",A2:A80)

  7. #7
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Average of every nth row

    Quote Originally Posted by Jonmo1 View Post
    =AVERAGEIF(A$1:A$79,"?*",A2:A80)
    I'm having one of those face meets palm moments for missing something so obvious

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

    Re: Average of every nth row

    @jason

    I wouldn't call it 'obvious'
    It does require a little 'outside the box' thinking, and not fixating on the every nth thing.

    Whenever I see a request for average/count/sum every nth row/column, I ALWAYS look for some sort of key that can be used instead.

  9. #9
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Average of every nth row

    Maybe not the most obvious of obvious things, Jonmo, but given how often I use the method of offsetting the ranges between the arguments of a function to achieve the desired result from misaligned data, I am a little disappointed with myself lol.

    Even if I had seen it, not sure that I would have noticed the absolute row on the criteria to enable vertical and horizontal fill though.

    I threw the box in the trash long ago, but occasionally somebody gives me a new one to think inside of

  10. #10
    Registered User
    Join Date
    08-15-2016
    Location
    London
    MS-Off Ver
    2007
    Posts
    6

    Re: Average of every nth row

    Cheers Jonmo and Jason,

    Worked perfectly

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

    Re: Average of every nth row

    You're welcome.

+ 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. SumProduct N/A Error, Quarterly Average, Running Average, From and to Userform
    By Sorjas in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 01-18-2015, 07:40 PM
  2. [SOLVED] need formula to average cells but if one cell has N/A then dont average and input N/A
    By CityInspector in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 08-08-2013, 04:16 PM
  3. [SOLVED] Find Average, Return Column Header of Number Closest To Average
    By djmyers in forum Excel Formulas & Functions
    Replies: 15
    Last Post: 07-07-2013, 04:19 PM
  4. Replies: 14
    Last Post: 06-14-2013, 09:00 PM
  5. Replies: 10
    Last Post: 04-25-2013, 06:12 PM
  6. displaying numbers whoes average is as close prefered average.
    By aakhan107 in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 11-18-2012, 01:14 AM
  7. The rank of average ranks excluding empty cells but including their average.
    By Terminal45 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 10-21-2012, 03:44 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