+ Reply to Thread
Results 1 to 9 of 9

Average of a column excluding certain rows

  1. #1
    Registered User
    Join Date
    01-06-2009
    Location
    calgary, alberta, canada
    MS-Off Ver
    Excel 2003
    Posts
    7

    Average of a column excluding certain rows

    hi,
    I am trying to determine the average of a column of data while excluding some rows in that column. i have the row numbers that i want to exclude. Is there any way to determine the average without having to physically delete the rows.
    any help is greatly appreciated! thanks!

  2. #2
    Forum Expert
    Join Date
    12-23-2006
    Location
    germany
    MS-Off Ver
    XL2003 / 2007 / 2010
    Posts
    6,326
    Hi and welcome to the board,
    how do you determine the rows to exclude?

  3. #3
    Registered User
    Join Date
    01-06-2009
    Location
    calgary, alberta, canada
    MS-Off Ver
    Excel 2003
    Posts
    7
    Thank you,
    the rows are determined through a function which searches through another table to MATCH the values in the column. Meaning, that if a certain value exists in the table it would give me the row number for it.
    i hope this makes sense.. lol

  4. #4
    Forum Expert
    Join Date
    12-23-2006
    Location
    germany
    MS-Off Ver
    XL2003 / 2007 / 2010
    Posts
    6,326
    Sense, maybe, but I don't get it. Could you post a small example with some details please?

  5. #5
    Registered User
    Join Date
    01-06-2009
    Location
    calgary, alberta, canada
    MS-Off Ver
    Excel 2003
    Posts
    7
    ok so let's say that i want to calculate the average of the following column A

    A
    2
    3
    4
    5
    3
    5

    But what i want is to exlude 3 and 5 (rows 2 and 4) from the average.
    Is there any way that i can do that?

  6. #6
    Registered User
    Join Date
    12-30-2008
    Location
    Vermont, USA
    MS-Off Ver
    Excel 2003
    Posts
    64
    I'm not sure how your data are structured (specifically, where are these row numbers listed that identify items to exclude?), but it sounds like the AVERAGE function might not work for this. However, if you can identify the rows in some sort of binary fashion (e.g., "INCLUDE", "EXCLUDE"), you could use a SUMIF for the total and COUNTIF for the n, for example, like this:

    =SUMIF(B:B,"INCLUDE",A:A)/COUNTIF(B:B,"INCLUDE")

    where column B identifies each row as either INCLUDE or EXCLUDE and column A contains the numbers you want to average.

    Would that work?

    To identify rows, perhaps you could use a function in column B like:

    =IF(COUNTIF(E:E,ROW()),"EXCLUDE","INCLUDE")

    where Column E contains a list of all row numbers to exclude.
    Last edited by clownfish; 01-06-2009 at 04:04 PM.

  7. #7
    Registered User
    Join Date
    12-30-2008
    Location
    Vermont, USA
    MS-Off Ver
    Excel 2003
    Posts
    64
    On second thought, the solution I provided above is kind of silly, since if you're going to identify rows to include/exclude, you might as well just have the IF function pull the values you want to average from Col A to Col B and then use AVERAGE:

    so, in B2, type this (assuming your data are in Col A starting at A2):

    =IF(COUNTIF(E:E,ROW()),A2,"")

    and somewhere else, type this:

    =AVERAGE(B:B)

  8. #8
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Averaging a subset of a range

    Just a thought....
    If you can have a column that flags the rows to be ignored...eg a formula
    that returns Show/Hide, use and AutoFilter to hide the unwanted rows.

    Then you can use this version of the SUBTOTAL function:

    Please Login or Register  to view this content.
    That function will ignore anything in hidden filtered rows.
    ...or...if you hide the rows manually...use this variation:
    Please Login or Register  to view this content.

    It will ignore ANY hidden row.

    Other options for SUBTOTAL parameters:

    Please Login or Register  to view this content.
    Note: Adding 100 to any of those FuncNums causes the SUBTOTAL function to ignore HIDDEN rows, not just hidden FILTERED rows.

    Example: =SUBTOTAL(103,A1:A20) counts non-blank, non-hidden cells.
    Ron
    Former Microsoft MVP - Excel (2006 - 2015)
    Click here to see the Forum Rules

  9. #9
    Registered User
    Join Date
    01-06-2009
    Location
    calgary, alberta, canada
    MS-Off Ver
    Excel 2003
    Posts
    7
    thank you for all the replies!
    what i ended up doin is that i identified the rows that i did not need by using a Vlookup function then, replaced the value of the rows that i did not need with blanks that way i was able to use the average function.
    again thank you for the input however!

+ Reply to Thread

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