+ Reply to Thread
Results 1 to 13 of 13

Counting frequencies in one row

  1. #1
    Registered User
    Join Date
    04-03-2017
    Location
    France
    MS-Off Ver
    Office 2010
    Posts
    5

    Counting frequencies in one row

    Hi everybody,

    I am looking for a way/formulas/function to solve my problem. I get a database from a questionnaire and one of the questions have multiple answers that you could combine (e.g. a, b, c and d) and as a results I get:

    1 - a
    2 - a + b + c
    3 - b + d
    etc.


    I would like to know if it's possible to easily count the a, b, c and d separately (giving here: a:2, b:2, c:1 and d:1).

    Hope my question is clear enough.

    Thanks

  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,202

    Re: Counting frequencies in one row

    Attach a sample workbook. Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.

  3. #3
    Registered User
    Join Date
    04-03-2017
    Location
    France
    MS-Off Ver
    Office 2010
    Posts
    5

    Re: Counting frequencies in one row

    Thanks for your reply.

    Please find enclosed the example.

    I did not make all the counting so the XX should be replaced by the number of times the month appear in the month column.
    Attached Files Attached Files

  4. #4
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,466

    Re: Counting frequencies in one row

    Assuming A1:A4 contain strings

    D1 ="a" (or b,c,d,...)

    Try:

    =SUMPRODUCT(LEN($A$1:$A$4)-LEN(SUBSTITUTE($A$1:$A$4,D1,"")))
    Quang PT

  5. #5
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,466

    Re: Counting frequencies in one row

    With your sample,

    =SUMPRODUCT(LEN(fromquestionnaire!$B$2:$B$87)-LEN(SUBSTITUTE(fromquestionnaire!$B$2:$B$87,A2,"")))/LEN(A2)

    be warned with typo "Decemper" in last rows

  6. #6
    Forum Expert
    Join Date
    12-03-2009
    Location
    Florence, Italy
    MS-Off Ver
    Excel 2019
    Posts
    1,796

    Re: Counting frequencies in one row

    Hi All

    in B2 to be copied down

    =COUNTIF(fromquestionnaire!B:B,"*"&A2&"*")

    February should return 72

    Regards
    -----------------------------------------------------

    At Excelforum, you can say "Thank you!" by clicking the star icon ("Add Reputation") below the post.

    Please, mark your thread [SOLVED] if you received your answer.

  7. #7
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2016
    Posts
    5,910

    Re: Counting frequencies in one row

    Or count "a":

    =COUNTIF(A1:A4,"*a*")

  8. #8
    Registered User
    Join Date
    04-03-2017
    Location
    France
    MS-Off Ver
    Office 2010
    Posts
    5

    Re: Counting frequencies in one row

    Thanks for your reply.

    I get some different results if I use the SUMPRODUCT or the COUNTIF formula?
    Which one is more relevant? It seems that countif is more accurate.
    Last edited by letime64; 04-03-2017 at 06:10 AM.

  9. #9
    Forum Expert avk's Avatar
    Join Date
    07-12-2007
    Location
    India
    MS-Off Ver
    Microsoft Office 2013
    Posts
    3,223

    Re: Counting frequencies in one row

    Try with in "B2"
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    copy paste down
    Note : You need to change month as per specified
    Last edited by avk; 04-03-2017 at 06:10 AM. Reason: Changes


    atul


    If my answer (or that of other members) has helped you, please say "Thanks" by clicking the Add Reputation button at the foot of one of their posts.

    Also: if your problem is solved, please take the time to mark your thread as SOLVED by going to the top of your first post, selecting "Thread Tools" and then "Mark thread as solved".

  10. #10
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,466

    Re: Counting frequencies in one row

    Quote Originally Posted by letime64 View Post
    Woooh ! Great ! It's working, thanks a lot.

    Could you explain the logic behind it? I understand the LEN function and the idea of comparing the length of the text but I don't get the use of the other formulas (and how to avoid miscounting of june and july for example with both 4 letters).

    Thanks again
    Nice to hear it works.
    Let say we have string in cell A1 = "zzzzabcyyyyabc" in which we 'd like to count "abc" as twice.
    if we use SUBSTITUTE to eliminate "abc" like this: SUBSTITUTE(A1,"abc",""), returns "zzzzyyyy"
    LEN(A1)-LEN(SUBSTITUTE(...)) = 14-8=6, with 6 is total lenght of number of "abc"
    Now divide to 3 (length of "abc")

  11. #11
    Registered User
    Join Date
    04-03-2017
    Location
    France
    MS-Off Ver
    Office 2010
    Posts
    5

    Re: Counting frequencies in one row

    Quote Originally Posted by bebo021999 View Post
    Nice to hear it works.
    Let say we have string in cell A1 = "zzzzabcyyyyabc" in which we 'd like to count "abc" as twice.
    if we use SUBSTITUTE to eliminate "abc" like this: SUBSTITUTE(A1,"abc",""), returns "zzzzyyyy"
    LEN(A1)-LEN(SUBSTITUTE(...)) = 14-8=6, with 6 is total lenght of number of "abc"
    Now divide to 3 (length of "abc")
    Sorry I edited my post as it is not working compared to countif, more easy to use and more acurate. Thank you for your help and the explanation.

  12. #12
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,466

    Re: Counting frequencies in one row

    2 options with COUNTIF and LEN for you!

    If A1 like this:

    "January-February...", COUNTIF is best choice

    but, If A1 like this:

    "January-February-January...", LEN(SUBSTITUTE... is acurate.

  13. #13
    Registered User
    Join Date
    04-03-2017
    Location
    France
    MS-Off Ver
    Office 2010
    Posts
    5

    Re: Counting frequencies in one row

    Quote Originally Posted by bebo021999 View Post
    2 options with COUNTIF and LEN for you!

    If A1 like this:

    "January-February...", COUNTIF is best choice

    but, If A1 like this:

    "January-February-January...", LEN(SUBSTITUTE... is acurate.

    Thanks, I am in the first case so i will go for the countif but i keep in mind the LEN solution.

+ 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. Stoppage Frequencies
    By cutebeach in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 10-24-2016, 11:43 PM
  2. [SOLVED] Repeat the number according to its frequencies
    By kuntalnr in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 11-17-2013, 07:12 PM
  3. Percentiles and frequencies
    By lldsandsll in forum Excel General
    Replies: 6
    Last Post: 07-12-2012, 11:11 AM
  4. Excel 2007 : Multiple frequencies
    By freehawk in forum Excel General
    Replies: 9
    Last Post: 05-20-2011, 03:52 PM
  5. Frequencies of occurancies in range
    By vu2 in forum Excel General
    Replies: 2
    Last Post: 09-25-2007, 04:30 PM
  6. [SOLVED] graphing data of different frequencies
    By Bob in forum Excel Charting & Pivots
    Replies: 3
    Last Post: 06-12-2006, 03:25 PM
  7. Calculating frequencies
    By Gene Goldenfeld in forum Excel General
    Replies: 11
    Last Post: 12-02-2005, 01:55 AM

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