+ Reply to Thread
Results 1 to 4 of 4

Help with formula for counting occurances of text in collumns

  1. #1
    Registered User
    Join Date
    11-30-2009
    Location
    Newport, Wales
    MS-Off Ver
    Excel 2007
    Posts
    3

    Help with formula for counting occurances of text in collumns

    Hi,

    I'm currently at University collecting data for my dissertation and using Excel makes calculations much simpler and quicker, once you know how to use it. I have used Google Documents to create a form and then downloaded the data to Excel for analysis and have used the following formula to count the number of time people have answered yes to a question:

    {=SUM(LEN(F2:F1000)-LEN(SUBSTITUTE(F2:F1000,"Yes","")))/LEN("Yes")}

    All working fine there. However, I want to know if it is possible and if so how, I can create a formula to find of those people who have answered Yes to one question, then answered No to another. I know it doesn't work but along the lines of:

    =SUM(LEN(F2:F1000)-LEN(SUBSTITUTE(F2:F1000,"Yes","")))/LEN("Yes") AND SUM(LEN(H2:H1000)-LEN(SUBSTITUTE(H2:H1000,"No","")))/LEN("No")

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Help with formula for counting occurances of text in collumns

    Hi,

    The formulae you are using are array formulae which are not particularly efficient in terms of speed. You'd be better using a helper column to test whether the two fields in question in each row are Yes and No, and then use a simple =SUM() to total the number of rows that meet the criteria.

    For instance if A and B hold the Yes/No answers then use

    Please Login or Register  to view this content.
    Then =SUM(<helper column>)

    HTH
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Valued Forum Contributor khamilton's Avatar
    Join Date
    10-08-2009
    Location
    IL
    MS-Off Ver
    Excel 2007
    Posts
    345

    Re: Help with formula for counting occurances of text in collumns

    Maybe try something like this:=countifs(F2:F1000,"Yes",H2:H1000,"No")

  4. #4
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Help with formula for counting occurances of text in collumns

    If the strings are embedded (I assume that's why you're using the SUBSTITUTE array) then you can still use the COUNTIFS as illustrated (assuming as per profile you're using XL2007), however, you will need to utilise wildcards within the criteria, ie

    =COUNTIFS(F2:F1000,"*Yes*",H2:H1000,"*No*")

    of course the above, like your original, is still open to error should either term appear within a word, eg

    H2: "Yes, It Snowed"

    would still count as a No... if there is inconsitent punctuation (delimiters) then it can be hard to ensure you'll always get a 100% accurate result even if revert to a more sophisticated approach like SUMPRODUCT (which would allow you to manipulate the source values within the calculation itself).

+ 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