+ Reply to Thread
Results 1 to 6 of 6

How-to: Extract, count and rank text occurrences

Hybrid View

  1. #1
    Registered User
    Join Date
    01-16-2019
    Location
    Berlin
    MS-Off Ver
    Excel 2010
    Posts
    3

    How-to: Extract, count and rank text occurrences

    Hello everyone,

    I kindly request assistance with the following Excel problem that's bugging me at the moment. The starting table looks as follows, two roes:

    Text A Occurence 1
    Text A Occurence 2
    Text B Occurence 1
    ...

    I need to do the following in Excel 2010:

    1. In column A, identify the most common occurrences of text, the most common minus 1, the most common minus 2 and so on for the first 5 most common texts. The first 5 most common items should be identified.
    2. Rank these 5 texts with regard to their frequency.
    3. Produce a final output that looks something like this:

    Text B 21 times
    Text A 12 times
    Text C 6 times
    ...

    Note: I do not necessarily need to know the actual number of occurrences, but need to have a text list of the 5 most common strings in ranked order. I know this must probably be done using an interim or helper table, but can't figure out how to do it.

    Can someone help?`

    Thank you very much!

    Bijan

  2. #2
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2406
    Posts
    44,662

    Re: How-to: Extract, count and rank text occurrences

    Will you please attach a SMALL sample Excel workbook (10-20 rows of data is usually enough)? However, please give us an indication of the approximate number of rows of data you want the solution to work with (100, 1000, 100,000 or whatever). Please don't attach a picture of an Excel sheet (no-one will want to re-type all your stuff before starting).

    1. It does NOT have to be your real sheet - mock up a SAMPLE if you need to. But not 1000's of rows!!! It makes manual checking so tedious. Whatever you do... make sure that all confidential information is removed first!!

    2. Make sure that your sample data are truly REPRESENTATIVE of your real data. The use of unrepresentative data is very frustrating and can lead to long delays in reaching a solution.

    3. Make sure that your desired solution is also shown (mock up the results manually).

    4. Try to avoid using merged cells. They cause lots of problems!

    Unfortunately the attachment icon doesn't work at the moment. So, to attach an Excel file you have to do the following: Just before posting, scroll down to Go Advanced and then scroll down to Manage Attachments. Now follow the instructions at the top of that screen.
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU

  3. #3
    Registered User
    Join Date
    01-16-2019
    Location
    Berlin
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: How-to: Extract, count and rank text occurrences

    Sure, please find the file enclosed. I would to know:

    1. What are the 5 most common media types (column "Medium")
    2. Rank these with regard to commonality/frequency of occurence
    3. Feed these 5 into a pie diagram that outputs these graphically
    Attached Files Attached Files

  4. #4
    Forum Expert KOKOSEK's Avatar
    Join Date
    08-03-2018
    Location
    Pole in Yorkshire, UK
    MS-Off Ver
    365/2013
    Posts
    2,765

    Re: How-to: Extract, count and rank text occurrences

    There are only 2 types of media, so it is hard to find 5 most common

    Into cell E2:

    =IFERROR(INDEX(B$2:B$35,MODE(IF(COUNTIF(E$1:E1,B$2:B$35)=0,MATCH(B$2:B$35,B$2:B$35,0)+{0,0}))),"")

    and CSE not just Enter. Then copy down 4 times (to get 5 the most common).
    Expand range of rows (bolded) as you need.

    and into cell F2:

    =IF(E2<>"",COUNTIF(B:B,E2),"")

    and copy down as above, as many times as you need.

    Come on, you can create chart yourself.

  5. #5
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2406
    Posts
    44,662

    Re: How-to: Extract, count and rank text occurrences

    I added a few more categories. I also posted a sheet, as you WILL need ; instead of , and may need a completely different separator in the array constant:

    {0,0}

    The Sheet should "translate" it into German for you...
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    01-16-2019
    Location
    Berlin
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: How-to: Extract, count and rank text occurrences

    Thanks KOKOSEK, thanks Glenn! That was extremely helpful and solved my problem in no time. Thanks!

+ 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. Count number of occurrences of text in URL
    By james19 in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 04-04-2017, 11:17 AM
  2. How to count occurrences of text
    By knuckledownlacrosse in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 06-18-2015, 01:16 PM
  3. [SOLVED] Count occurrences of text between blanks
    By Tannenbaum1 in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 12-16-2014, 01:17 PM
  4. Replies: 13
    Last Post: 08-28-2014, 08:00 PM
  5. count the occurrences of text
    By Elainefish in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 05-01-2013, 09:32 AM
  6. Replies: 3
    Last Post: 01-09-2013, 07:55 PM
  7. Count occurrences of text with various criteria
    By ludgirardi in forum Excel - New Users/Basics
    Replies: 4
    Last Post: 12-20-2012, 05:31 AM

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