+ Reply to Thread
Results 1 to 13 of 13

Average a list of data with blanks and text

  1. #1
    Registered User
    Join Date
    09-23-2014
    Location
    Wisconsin
    MS-Off Ver
    2013
    Posts
    28

    Average a list of data with blanks and text

    I'm looking to find averages based on survey responses. Trouble is, the data is not always complete. There are some blank values as well as text in the data. I'm not sure if I need to clean up the data first or if I can create an average function statement that will look at the "bad" data within the process. I've attached the file that I'm working with.

    Each column will be averaged separately. Column B works just fine averaging since there's no bad data. Column C works as well. I'm struggling with columns D & E where there are NAs. Those responses should be counted in the count, but should have a value of 0 in the average function.

    Can someone please help me figure out how to get the averages of each column? Much appreciated!
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,301

    Re: Average a list of data with blanks and text

    Try

    =SUM(D2:D83)/COUNTA(D2:D83)

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

    Re: Average a list of data with blanks and text

    If the count and sum values are correct then average =SUM/COUNT, or =K3/K2

    Keep an eye on your blank cells, they appear to contain a null value, which differs from an empty cell, if that changes then your formulas will give incorrect results.

    To see what I mean, there are 2 empty cells in D2:D83, double click in one, then press enter, this will clear the null value which causes COUNTA to ignore it, but COUNTBLANK to count it, giving an incorrect result in K2.

  4. #4
    Registered User
    Join Date
    09-23-2014
    Location
    Wisconsin
    MS-Off Ver
    2013
    Posts
    28

    Re: Average a list of data with blanks and text

    Thanks Jason.b75. This is my problem. There are inconsistencies between blank and null values. The way the data sits now, I cannot rely on my count and sum values as you mention in your first paragraph.

    Is my resolution to clear all null values first or is it possible to use a combination of a SUM/COUNT/IFERROR/ISBLANK formula? If I can do the latter, I'm not sure how.

    My total count of responses in all but column F should be 80. I don't get that count consistently using the COUNT function (as you can see in cells K2 and L2).

  5. #5
    Registered User
    Join Date
    09-23-2014
    Location
    Wisconsin
    MS-Off Ver
    2013
    Posts
    28

    Re: Average a list of data with blanks and text

    Thanks for the reply, John. However, COUNTA doesn't work for every column. I need a consistent formula that I can copy from column to column. This workbook is much larger than the small sampling of data I posted on this thread.

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

    Re: Average a list of data with blanks and text

    I've been trying this as an alternative method, and haven't found any data types that cause problems so far.

    =(COUNT(D2:D83)+COUNTIF(D2:D83,"?*"))

    You could also try

    =SUMPRODUCT(--(D2:D83<>""))

    Both of these will (or at least should) produce the correct counts with blank or empty cells, the first one will also ignore a cell containing a single space if an erroneous one happens to find its way into your sheet.

    You should then be able to use that for SUM/COUNT to get the average required.

    edit:- changed formulas, original ones involved major common sense failure
    Last edited by jason.b75; 12-31-2015 at 08:52 AM.

  7. #7
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,945

    Re: Average a list of data with blanks and text

    Just for testing, I created a helper column (O) with this copied down...
    =IF(ISNUMBER(D2),D2,"")

    I then averaged that column with...
    =AVERAGE(O2:O83)
    and then comapred that with using the same formula in D...
    =AVERAGE(D2:D83)

    Both gave the exact same answer, not sure if that is what you were going for?
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

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

    Re: Average a list of data with blanks and text

    Ford, that will only average numeric values.

    Looking at the data in column D
    73 numeric values
    7 text strings
    2 blanks

    Using AVERAGE will give SUM/73 (count of numeric values), my understanding is that the requirement is SUM/80 (count of non blank cells, which could be null strings or empty cells).

    Something on the lines of

    =SUM(D2:D83)/(COUNT(D2:D83)+COUNTIF(D2:D83,"?*"))

    Which, using the sample data, will reduce the result from 3.38 to 3.09.

    I'm sure there is a dead basic method that I'm missing

  9. #9
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,386

    Re: Average a list of data with blanks and text

    The blank cells are not blank in column D: they have in fact got one space in them (i.e. they are " "), so they are also being counted as text, hence the incorrect counts.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

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

    Re: Average a list of data with blanks and text

    Ali,

    If you test that with =LEN(D15) you will see that it returns 0, where a single space would still have a length of 1 character.

    The cell actually contains a null string, which could be the result of copy / paste, or the format of data from an external source.

    Try using copy / pastespecial - values on a formula that returns "", the cell will appear blank / empty but any formula referring to it will still see it as text because of the null value left by "".

    Select the cell, then press f2 to enter edit mode, and without deleting anything, press enter, this clears the null value, a space would still be left in the cell.

  11. #11
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,386

    Re: Average a list of data with blanks and text

    Yes, Jason - I see that now - but test it with various counts and you will see that it is skewing them, which is my point, really.

  12. #12
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,301

    Re: Average a list of data with blanks and text

    Try

    =SUM(D2:D83)/SUMPRODUCT(--(D2:D83<>""))

    (based on several previous posts) results in average of 3.0875 (Posts #6 & #8 from Jason)

    the SUMPRODUCT results in count of 80.

  13. #13
    Registered User
    Join Date
    09-23-2014
    Location
    Wisconsin
    MS-Off Ver
    2013
    Posts
    28

    Re: Average a list of data with blanks and text

    Thank you for all of your help! It turned out that I had to convert my columns to numbers from text in order for the average function to work out as it should. As it turns out, the user who made this request to me did NOT want to use the data that was null/text, etc. in the average formula.

+ 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] List unused items from data validation list without blanks
    By L plates in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 02-27-2015, 09:02 AM
  2. Unique list - ignore blanks and text
    By pauldaddyadams in forum Excel General
    Replies: 6
    Last Post: 02-18-2015, 05:57 AM
  3. [SOLVED] Rolling average with data in a row using only last 10 entries ignoring blanks
    By Lasers Reef in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 08-22-2013, 09:37 PM
  4. Replies: 6
    Last Post: 01-07-2013, 08:58 PM
  5. Replies: 6
    Last Post: 12-07-2011, 01:45 PM
  6. Replies: 1
    Last Post: 05-13-2009, 02:40 AM
  7. [SOLVED] Weighed Average of a weiged average when there are blanks
    By krl - ExcelForums.com in forum Excel General
    Replies: 1
    Last Post: 07-06-2005, 03:05 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