+ Reply to Thread
Results 1 to 4 of 4

Need to Count number of unique rows for desired value

  1. #1
    Registered User
    Join Date
    10-19-2012
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    5

    Need to Count number of unique rows for desired value

    Hello,

    I'm working on a spreadsheet and I have run into an issue that I have not been able to get around yet. I searched around the forum but have not found an answer so far. Any help would be appreciated.

    The problem is as follows:

    I have 3 columns. The first tracks the date, the second the country, and the third the expense that was incurred.


    1/1/2013 Canada $45
    1/1/2013 Canada $56
    1/3/2013 Canada $15
    1/3/2013 Uganda $23
    1/3/2013 Uganda $25
    1/5/2013 Canada $55
    1/5/2013 Canada $45


    For my purposes the expense column is not important, I just included it here to clarify the purpose of the spreadsheet. For each date there could be no entries, or multiple entries. I need to find out how many individual days exist for a country that I am searching for. So in the example above, the answer would be 3 if I searched for Canada, and 1 if I searched for Uganda.

    I have attached a sample spreadsheet. I've been trying to find a solution using match, countifs and similar functions, but I can't come up with a formula that works. Any help would be greatly appreciated.

    Peter
    Attached Files Attached Files

  2. #2
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,929

    Re: Need to Count number of unique rows for desired value

    Hi

    Try this...

    I added a helper column in D and used this, copied down...
    =IF(AND(COUNTIF($A$2:A2,A2)>1,B2=B1),"",1)

    tthen used this to do the count...
    =COUNTIFS($B$2:$B$14,"Canada",$D$2:$D$14,1)

    Either put the counties in a list (prefered), or change 1 country to the next inside the formula
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  3. #3
    Forum Expert icestationzbra's Avatar
    Join Date
    01-07-2004
    MS-Off Ver
    2007, 2010
    Posts
    1,421

    Re: Need to Count number of unique rows for desired value

    ARRAY formula in G3:

    Please Login or Register  to view this content.
    or regular formula:

    Please Login or Register  to view this content.
    replace Canada with Portugal for G7.

    does that help?
    - i.s.z -
    CSE, aka Array aka { }, formulae are confirmed with CONTROL+SHIFT+ENTER.
    Replace commas ( , ) with semicolons ( ; ) in formulae, if your locale setting demands.
    All good ideas are courtesy resources from this forum as well as others around the web.
    - e.o.m -

  4. #4
    Registered User
    Join Date
    10-19-2012
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Need to Count number of unique rows for desired value

    Thank you FDibbins, this worked great and was quite simple.

    Peter

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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