+ Reply to Thread
Results 1 to 5 of 5

Formula to count unique strings broken down by month

  1. #1
    Registered User
    Join Date
    02-26-2014
    Location
    Dorset, England
    MS-Off Ver
    Excel 2010
    Posts
    4

    Formula to count unique strings broken down by month

    Hello all,

    I have been struggling with this for a while so joined the forum so I can ask the experts .

    I am trying to count the number of unique entries in a column (a) broken down by month (column c).
    The data in column a is alphanumeric so I have been unable to use frequency.
    I have attached an example which should hopefully make things clearer. I have highlighted the cells where I need a solution and have added a table of expected results.

    I have a formula which calculates the totals by month but it counts all entries and doesn't ignore repeated entries.

    =IF(COUNTIF($C$2:$C$19,8)=0,"0",(COUNTIF($C$2:$C$19,8)))

    Via a google search I found that you could use the following formula (as an array) to calculate the total unique entries but I am unable to adapt it to allow for the month variable;

    {=SUMPRODUCT((A2:A19<>"")/COUNTIF(A2:A19,A2:A19&""))}

    Any suggestions would be gratefully received.

    Thanks
    Attached Files Attached Files

  2. #2
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: Formula to count unique strings broken down by month

    Try this one

    You don't need Ctrl+Shift+Enter for this formula

    =SUMPRODUCT(($A$2:$A$19<>"")*(TEXT($B$2:$B$19,"mmmm")=TEXT(A24,"mmmm"))/COUNTIF(A$2:A$19,$A$2:$A$19&""))
    If you like my answer please click on * Add Reputation
    Don't forget to mark threads as "Solved" if your problem has been resolved

    "Nothing is so firmly believed as what we least know."
    --Michel de Montaigne

  3. #3
    Registered User
    Join Date
    02-26-2014
    Location
    Dorset, England
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Formula to count unique strings broken down by month

    Hi AlKey

    Thank you for the prompt reply.

    It appeared to work perfectly on the example, however, when I tried it in the actual spreadsheet (with the ranges / references amended) I got some unexpected results.

    I have attached another example (v2) which mirrors my data and has your formula in place.

    As you can see the last three entries (Oct to Dec) are coming up with a fractional result. They are very close to the expected result and I have tried to trouble shoot it myself but it is approaching the end of my day and I don't think my brain can cope any more

    Thanks in advance.
    Attached Files Attached Files

  4. #4
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: Formula to count unique strings broken down by month

    Please see attached file with updated formula in column G. It was a rounding issue.

    You're welcome and thank you for your feedback!

    Please mark thread as "Solved" if your issue has been resolved. (Selecting Thread Tools-> Mark thread as Solved).
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    02-26-2014
    Location
    Dorset, England
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Formula to count unique strings broken down by month

    Hi AlKey

    It works perfectly. Thanks very much.

    I can't believe I didn't see that. It had been a long day.

  6. #6
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Formula to count unique strings broken down by month

    Quote Originally Posted by AlKey View Post
    It was a rounding issue.
    Yes, because you can't reliably use SUMPRODUCT/COUNTIF to count uniques with a condition.

    Use this array formula**:

    =SUM(IF(FREQUENCY(IF(TEXT(B$2:B$241,"mmmm")=E3,MATCH(A$2:A$241,A$2:A$241,0)),ROW(A$2:A$241)-ROW(A$2)+1),1))

    ** array formulas need to be entered using the key
    combination of CTRL,SHIFT,ENTER (not just ENTER).
    Hold down both the CTRL key and the SHIFT key
    then hit ENTER.
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

+ 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] Formula to Count Unique Customer by Month
    By byankton in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 12-19-2013, 12:39 AM
  2. [SOLVED] Broken Count formula
    By Notters in forum Excel General
    Replies: 1
    Last Post: 08-21-2012, 09:06 AM
  3. Count unique for specific month
    By Bob@Sun in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-17-2011, 02:52 PM
  4. Count unique days within month
    By jirib in forum Excel General
    Replies: 7
    Last Post: 08-26-2010, 06:12 PM
  5. Count Unique Strings
    By [email protected] in forum Excel General
    Replies: 4
    Last Post: 04-27-2005, 03:06 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