+ Reply to Thread
Results 1 to 9 of 9

Thread: 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
    6

    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
    Extremely Helpful member
    Join Date
    12-23-2006
    Location
    Belgium
    MS-Off Ver
    XL2003
    Posts
    6,127
    Hi and welcome to the board,
    how do you determine the rows to exclude?
    Quoting entire posts clutters the forum and makes threads hard to read !

    If you are pleased with a member's answer then use the Star icon to rate it

    Click here to see forum rules

  3. #3
    Registered User
    Join Date
    01-06-2009
    Location
    calgary, alberta, canada
    MS-Off Ver
    Excel 2003
    Posts
    6
    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
    Extremely Helpful member
    Join Date
    12-23-2006
    Location
    Belgium
    MS-Off Ver
    XL2003
    Posts
    6,127
    Sense, maybe, but I don't get it. Could you post a small example with some details please?
    Quoting entire posts clutters the forum and makes threads hard to read !

    If you are pleased with a member's answer then use the Star icon to rate it

    Click here to see forum rules

  5. #5
    Registered User
    Join Date
    01-06-2009
    Location
    calgary, alberta, canada
    MS-Off Ver
    Excel 2003
    Posts
    6
    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 03: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
    Cheeky Forum Moderator Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2003, 2007, 2010
    Posts
    3,701

    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:

    =SUBTOTAL(1,A2:A100)
    That function will ignore anything in hidden filtered rows.
    ...or...if you hide the rows manually...use this variation:
    =SUBTOTAL(101,A2:A100)

    It will ignore ANY hidden row.

    Other options for SUBTOTAL parameters:

    Func Num__Function
    1_________AVERAGE
    2_________COUNT
    3_________COUNTA
    4_________MAX
    5_________MIN
    6_________PRODUCT
    7_________STDEV
    8_________STDEVP
    9_________SUM
    10_________VAR
    11_________VARP
    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.
    Regards,

    Ron
    Microsoft MVP - Excel
    (Oct 2006 - Sep 2012)

    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
    6
    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.2.0