+ Reply to Thread
Results 1 to 7 of 7

How to compute an average of numbers in columns that have numbers, text, blanks and NA?

  1. #1
    Registered User
    Join Date
    02-07-2012
    Location
    NJ, USA
    MS-Off Ver
    Excel 2007
    Posts
    42

    How to compute an average of numbers in columns that have numbers, text, blanks and NA?

    Dear Excel Gurus,

    I have a table with a large number of columns. Each column has some cells with numerical values and some cells with text, blanks or #N/A. For each column, I would like to compute the average of the numerical values in it. I can think of a couple of ways to do it (see below), but these ways "do not scale" if I have a large number of columns and a large number of possible numerical values. In the attached example I showed a very small table where I only have 2 columns (Result 1 and Result 2) that I need to summarize and where I know that all the numbers in these columns are integers between 1 and 5.

    1) I can set up a pivot table for each column (see "pivots" tab of the attached example). In each pivot I can filter out the non-numerical values in the column and then average the column. This clearly does not scale if I have many columns and/or if I have many different numerical values that can occur in each column (as opposed to the situation where I know that the only values that can occur are, say 1,2,3,4, or 5).
    2) Use sumif and countif to compute the sum and the number of numerical values for each column of the table, then compute the average for each column. I show this in rows 2 through 4 of "data" worksheet of the attached example. This clearly does not scale if I have many different numerical values that can occur in the Result 1 and Result 2 (as opposed to the situation where I know that the only values that can occur are, say 1,2,3,4, or 5).

    What I really want to do is something like "=COUNTIF(Table1[Result 1], isnumber())" and "=SUMIF(Table1[Result 1], isnumber())" But trying this gives me an error.

    Please let me know if there is a good way to do this (preferably without macros or VBA code).

    Many thanks!

    Studiosacountif sumif isnumber.xlsx

  2. #2
    Forum Expert Moo the Dog's Avatar
    Join Date
    09-28-2012
    Location
    Wisconsin
    MS-Off Ver
    Office 365 (PC & Mac)
    Posts
    1,845

    Re: How to compute an average of numbers in columns that have numbers, text, blanks and NA

    For averaging the columns, have you tried the AGGREGATE function to ignore errors?

    For Average:
    =AGGREGATE(1,6,Your_Range)

    For Sum:
    =AGGREGATE(9,6,Your_Range)

    - Moo

  3. #3
    Forum Expert Jakobshavn's Avatar
    Join Date
    08-17-2012
    Location
    Lakehurst, NJ, USA
    MS-Off Ver
    Excel 2007
    Posts
    1,970

    Re: How to compute an average of numbers in columns that have numbers, text, blanks and NA

    If you have a column of "stuff" that contains numbers, text, blanks, errors, and other junk, then the array formula:

    =AVERAGE(IF(ISNUMBER(A:A),A:A))

    will average the numbers. Array formulas must be entered with CNTRL-SHFT-ENTER rather than just the ENTER key.
    Gary's Student

  4. #4
    Forum Expert Jakobshavn's Avatar
    Join Date
    08-17-2012
    Location
    Lakehurst, NJ, USA
    MS-Off Ver
    Excel 2007
    Posts
    1,970

    Re: How to compute an average of numbers in columns that have numbers, text, blanks and NA

    Moo:

    AGGREGATE

    is available in Excel 2010 and maybe the Web app.

  5. #5
    Forum Expert Moo the Dog's Avatar
    Join Date
    09-28-2012
    Location
    Wisconsin
    MS-Off Ver
    Office 365 (PC & Mac)
    Posts
    1,845

    Re: How to compute an average of numbers in columns that have numbers, text, blanks and NA

    Thanks Jakob, I overlooked the OP's version - I usually check that, too.
    - Moo

  6. #6
    Registered User
    Join Date
    02-07-2012
    Location
    NJ, USA
    MS-Off Ver
    Excel 2007
    Posts
    42

    Re: How to compute an average of numbers in columns that have numbers, text, blanks and NA

    Jakobshavn,
    Thank you very much. This works!

    I am a bit puzzled what exactly it does. Looks like the if formula constructs a virtual table in computer memory where it applies the if statement element by element to the individual cells of column a. I am still shaky in my understanding of the array formula concept.

    Studiosa

    Quote Originally Posted by Jakobshavn View Post
    If you have a column of "stuff" that contains numbers, text, blanks, errors, and other junk, then the array formula:

    =AVERAGE(IF(ISNUMBER(A:A),A:A))

    will average the numbers. Array formulas must be entered with CNTRL-SHFT-ENTER rather than just the ENTER key.

  7. #7
    Forum Expert Jakobshavn's Avatar
    Join Date
    08-17-2012
    Location
    Lakehurst, NJ, USA
    MS-Off Ver
    Excel 2007
    Posts
    1,970

    Re: How to compute an average of numbers in columns that have numbers, text, blanks and NA


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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