+ Reply to Thread
Results 1 to 24 of 24

Trying to do Average of text as a string in a cell,getting these errors

  1. #1
    Forum Contributor
    Join Date
    06-23-2014
    Location
    USA
    MS-Off Ver
    2010
    Posts
    239

    Trying to do Average of text as a string in a cell,getting these errors

    Good morning everyone,

    I am trying to a average formula for text as a srtring in a cell. I am working with this formulas.

    First I tried this
    =AVG($A1:$A15)...this gave me this error...#DIV/0!

    So I then do this
    =AVG(IFERROR($A1:$A15)..that gives me this...to few arguments for this function, and highlights $A15)

    So I add this to the formula....
    {=AVG(IFERROR($A1:$A15,1),0)} this is a array because it is a string of text. The answer it gives is a 0 in the cell. So what am I doing wrong??

    Trying to find the average text string of text...ABCDEF,GHIJKL,AKBCDK,CDDFGG,AABCDF....ect
    Each string is within one cell, so "cell A1"has this data ABCDEF, "cell A2" has this data EFFDCB, "cell A3" has this data ABDCBA....so on and so forth...

    Need some help please.

    Thank you,

  2. #2
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Trying to do Average of text as a string in a cell,getting these errors

    Hi.

    Forgive me for not understanding, but what do you mean by an "average" in this context? Average is a mathematical concept applied to numbers only. How can you have an average of text strings?

    Do you perhaps mean the "most frequently occurring"? Or perhaps "occurring the median number of times"?

    Regards
    Click * below if this answer helped

    Advanced Excel Techniques: http://excelxor.com/

  3. #3
    Forum Contributor
    Join Date
    06-23-2014
    Location
    USA
    MS-Off Ver
    2010
    Posts
    239

    Re: Trying to do Average of text as a string in a cell,getting these errors

    Trying to find the average string of text within a range. So excel can look through each string and compare each letter and of that string and then produce a average text string of the overall it has compared. Anyone follow me?

  4. #4
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Trying to do Average of text as a string in a cell,getting these errors

    That's not clear at all, I'm afraid.

    Perhaps if you gave a small dataset of about 10 strings and said what you would expect the "average" of those strings to be.

    If we have something to go on then maybe we can help with the Excel work.

    Regards

  5. #5
    Forum Contributor
    Join Date
    06-23-2014
    Location
    USA
    MS-Off Ver
    2010
    Posts
    239

    Re: Trying to do Average of text as a string in a cell,getting these errors

    Here you go
    Attached Files Attached Files

  6. #6
    Forum Contributor
    Join Date
    06-23-2014
    Location
    USA
    MS-Off Ver
    2010
    Posts
    239

    Re: Trying to do Average of text as a string in a cell,getting these errors

    I guess I am trying to say is have excel count the occurrences of text with in a string then produce a average/mean/sum/ of the existing strings it looks at.

    Think of it like this.....1's and 0's

    111000
    101010
    001101
    111111
    000000
    001101
    110001
    then excel calculates the common string found between all of these...101011
    Last edited by b_rianv; 09-08-2014 at 11:43 AM.

  7. #7
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Trying to do Average of text as a string in a cell,getting these errors

    Sorry - you don't understand.

    What should be the result? You still haven't said what you mean by an "average" when it comes to text strings.

    Perhaps that means something to you, but until you share it with us we're not going to be any the wiser.

    Please state clearly your expected result(s) for the sample you just provided.

    Regards

  8. #8
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Trying to do Average of text as a string in a cell,getting these errors

    Quote Originally Posted by b_rianv View Post
    I guess I am trying to say is have excel count the occurrences of text with in a string then produce a average/mean/sum/ of the existing strings it looks at.

    Think of it like this.....1's and 0's

    111000
    101010
    001101
    111111
    000000
    001101
    110001
    then excel calculates the common string found between all of these...101011
    But that's just the problem I'm having. And excuse me if it's just me for not seeing it, but I don't see why 101011 is the "common" string amongst those.

    Can you explain why it is?

    Regards

  9. #9
    Forum Contributor
    Join Date
    06-23-2014
    Location
    USA
    MS-Off Ver
    2010
    Posts
    239

    Re: Trying to do Average of text as a string in a cell,getting these errors

    101011 is not, it is a EXAMPLE!! That is all. And that's is what excel would need to do is calculate the average of the strings it is looking at. So what formula or formulas needed might be ...Average, SUM, Countif, or whatever else I am trying to figure out.
    Last edited by b_rianv; 09-08-2014 at 12:41 PM.

  10. #10
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Trying to do Average of text as a string in a cell,getting these errors

    But you have to tell us the logic first!

    Excel is a machine! Unless we first give it a definition of what the average is for a range of text entries, then it can't do anything to help you.

    Like I said, it already has in-built functions to return the mathematical average for a series of numbers, but until you define what is meant by an "average" of text values, i.e. what results you would like to see, and why, then there's absolutely nothing I, nor Excel, can do to help you.

    So, given that dataset you gave above, try in your own words to explain what you think should be the average for those text values and why.

    If we can get your reasoning for one dataset, then we can look at building the logic into an Excel formula so that we can then apply that to as many datasets as we like. But at the moment you've given us absolutely nothing to go on.

    To repeat: there is no such thing as an average of text values per se. That definition is something you think should exist, but in fact doesn't.

    As such, you have to tell us what you think it should mean. Then maybe we can help you.

    Regards

  11. #11
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Trying to do Average of text as a string in a cell,getting these errors

    Hi Brian,

    Are all the strings 6 characters in length??
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  12. #12
    Forum Contributor
    Join Date
    06-23-2014
    Location
    USA
    MS-Off Ver
    2010
    Posts
    239

    Re: Trying to do Average of text as a string in a cell,getting these errors

    Sorry let me explain

    In a cell there are a total of 6 letters E and O. These letters make a pattern EEEOOO,EOOEOE,OOOOOO,EEOOOE,and I would like excel to count these letters that are in that pattern from range A1:A15 then calculate a pattern from what it just counted from that range AS the mean pattern. But I don't think excel can count individual letters in a cell and then calculate a pattern.

    Is that better

  13. #13
    Forum Contributor
    Join Date
    06-23-2014
    Location
    USA
    MS-Off Ver
    2010
    Posts
    239

    Re: Trying to do Average of text as a string in a cell,getting these errors

    Yes the pattern is 6 characters in lenght.

    Examples of patterns
    EEEEEE,OOOOOO,EEOOOO,EEEEOO,OOOOEE,OEEOOO,OEOOOO,EEEEOO,OEOEOO...ect
    Last edited by b_rianv; 09-08-2014 at 01:27 PM.

  14. #14
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: Trying to do Average of text as a string in a cell,getting these errors

    OK, assuming you have 6 letter strings of "E" and "O" only this formula will produce another 6 letter string of "E" and "O" with the most common letter in each position:

    =SUBSTITUTE(SUBSTITUTE(TEXT(SUMPRODUCT((MMULT({-1,1},COUNTIF(A1:A15,SUBSTITUTE("??????","?",{"E";"O"},{1,2,3,4,5,6})))>0)*10^{5,4,3,2,1,0}),"000000"),0,"E"),1,"O")

    If there are equal numbers of "E" and "O" in any position then you get "E" for that position
    Audere est facere

  15. #15
    Forum Contributor
    Join Date
    06-23-2014
    Location
    USA
    MS-Off Ver
    2010
    Posts
    239

    Re: Trying to do Average of text as a string in a cell,getting these errors

    So this formula will give me a average/mean pattern of "E" and "O" for the range this formula is looking at?

  16. #16
    Forum Contributor
    Join Date
    06-23-2014
    Location
    USA
    MS-Off Ver
    2010
    Posts
    239

    Re: Trying to do Average of text as a string in a cell,getting these errors

    Ok I am trying the formula =SUBSTITUTE(SUBSTITUTE(TEXT(SUMPRODUCT((MMULT({-1,1},COUNTIF

    (A1:A15,SUBSTITUTE("??????","?",{"E";"O"},{1,2,3,4,5,6})))>0)*10^

    {5,4,3,2,1,0}),"000000"),0,"E"),1,"O")

    And I am getting a error, excel highlight the whole formula.

    Any ideas??

    Never mind I got the formula to work!!!
    Last edited by b_rianv; 09-08-2014 at 02:42 PM.

  17. #17
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Trying to do Average of text as a string in a cell,getting these errors

    Try this UDF:
    Please Login or Register  to view this content.
    Use as:
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    If there is no mode for a given character position, it will return "?" for that character.
    let Source = #table({"Question","Thread", "User"},{{"Answered","Mark Solved", "Add Reputation"}}) in Source

    If I give you Power Query (Get & Transform Data) code, and you don't know what to do with it, then CLICK HERE

    Walking the tightrope between genius and eejit...

  18. #18
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: Trying to do Average of text as a string in a cell,getting these errors

    Quote Originally Posted by b_rianv View Post
    And I am getting a error, excel highlight the whole formula.
    OK, I put it in the worksheet - cell E2 highlighted
    Attached Files Attached Files

  19. #19
    Forum Contributor
    Join Date
    06-23-2014
    Location
    USA
    MS-Off Ver
    2010
    Posts
    239

    Re: Trying to do Average of text as a string in a cell,getting these errors

    Yea I got it to work after taking a look at it...Thanks

  20. #20
    Forum Contributor
    Join Date
    06-23-2014
    Location
    USA
    MS-Off Ver
    2010
    Posts
    239

    Re: Trying to do Average of text as a string in a cell,getting these errors

    Alright guys I will take a look at these tonight (formula and macro) when I get home from work.

  21. #21
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Trying to do Average of text as a string in a cell,getting these errors

    Quote Originally Posted by b_rianv View Post
    Alright guys I will take a look at these tonight (formula and macro) when I get home from work.
    It's worth noting that the UDF above will handle any length of strings (and even multiple lengths within the given range), any size range, and any text content (not just letters "E" and "O")

  22. #22
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,733

    Re: Trying to do Average of text as a string in a cell,getting these errors

    You kept asking for the "average", though you didn't really define what you meant by that. DDL's formula gives you the most frequent letter in any one position, but you could try this array* formula:

    =SUBSTITUTE(SUBSTITUTE(TEXT(DEC2BIN(ROUND(AVERAGE(BIN2DEC(SUBSTITUTE(SUBSTITUTE(A1:A15,"E","1"),"O","0"))),0)),"000000"),"1","E"),"0","O")

    This converts the Es and Os to a binary number for each cell in the range, then takes the average (rounded to an integer) and then converts it back to Es and Os.

    * NOTE: you must use the key combination of CTRL-SHIFT-Enter (CSE) to commit an array formula, rather than the usual <Enter>.

    The attached file shows my solution in blue, and DDL's in yellow.

    Hope this helps.

    Pete
    Attached Files Attached Files

  23. #23
    Forum Contributor
    Join Date
    06-23-2014
    Location
    USA
    MS-Off Ver
    2010
    Posts
    239

    Re: Trying to do Average of text as a string in a cell,getting these errors

    Pete's formula worked great, just what I was looking for. Olly macro is nice and DDL's formula is nice for positions. I will be using Pete's as it give a average of the patterns. But both OLLY'S and DDL's will be put to use else where in different projects. Thank you ALL for your hard work and helping me my problem.

  24. #24
    Registered User
    Join Date
    03-17-2014
    Location
    Lisbon, Portugal
    MS-Off Ver
    Excel 2013
    Posts
    16

    Re: Trying to do Average of text as a string in a cell,getting these errors

    Hi. Not sure of what you're trying to do. Counting the average of characters? Or the strings?

+ 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] need to use a text string inside range - errors
    By fredderf81 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-05-2013, 03:29 PM
  2. [SOLVED] Find partial text string within another text string return original text into cell.
    By mikey42979 in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 06-17-2013, 02:58 PM
  3. Replies: 14
    Last Post: 06-14-2013, 09:00 PM
  4. Replies: 1
    Last Post: 01-25-2011, 10:37 PM

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