+ Reply to Thread
Results 1 to 12 of 12

Get unique value if certain criteria met

Hybrid View

  1. #1
    Registered User
    Join Date
    11-07-2010
    Location
    Australia
    MS-Off Ver
    Excel 2003
    Posts
    6

    Get unique value if certain criteria met

    Hi
    Can someone please kindly assist?

    A B C
    1 Name Week Ending Date Hours
    2 Peter 2010/02/15 2
    3 David 2010/02/15 4
    4 Peter 2010/02/15 5
    5 David 2010/03/01 6
    6 Sam 2010/04/01 7
    7 Tom 2010/05/01 2

    These are the criteria.
    Cell A10 = Peter
    Cell A11 = David

    The formula in cell B8 =SUMPRODUCT(1/COUNTIF(B2:B7,B2:B7)) gives me the unique occurences within the range in column B.

    I need to find the number of unique occurences for the week ending dates for Peter and David.

    For Peter, unique count should be 1 and for David, unique count should be 2.
    Thanks.

    Thank you muchly if anyone can help.
    Last edited by arvarr; 11-07-2010 at 07:44 AM.

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Excel Formula Help !!!

    Your post does not comply with Rule 1 of our Forum RULES. Your post title should accurately and concisely describe your problem, not your anticipated solution. Use terms appropriate to a Google search. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will be addressed according to the OP's experience in the forum: If you have less than 10 posts, expect (and respond to) a request to change your thread title. If you have 10 or more posts, expect your post to be locked, so you can start a new thread with an appropriate title.
    To change a Title on your post, click EDIT then Go Advanced and change your title, if 2 days have passed ask a moderator to do it for you.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Registered User
    Join Date
    11-07-2010
    Location
    Australia
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: Excel Formula Help !!!

    Quote Originally Posted by royUK View Post
    Your post does not comply with Rule 1 of our Forum RULES. Your post title should accurately and concisely describe your problem, not your anticipated solution. Use terms appropriate to a Google search. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will be addressed according to the OP's experience in the forum: If you have less than 10 posts, expect (and respond to) a request to change your thread title. If you have 10 or more posts, expect your post to be locked, so you can start a new thread with an appropriate title.
    To change a Title on your post, click EDIT then Go Advanced and change your title, if 2 days have passed ask a moderator to do it for you.
    Thanks for the info. I have updated the title with correct info. now.

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Formula Help - Get unique value if certain criteria met

    It still contains unnecessary wording - "Formula Help"

  5. #5
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    16,042

    Re: Formula Help - Get unique value if certain criteria met

    arvarr, you can use this for counting unique occurances: =SUMPRODUCT((B2:B7<>"")/COUNTIF(B2:B7, B2:B7&"")).
    Your solution will give you error if there is blank value in the range.

    Solution for your problem after you adopt title name
    Never use Merged Cells in Excel

  6. #6
    Registered User
    Join Date
    11-07-2010
    Location
    Australia
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: Formula Help - Get unique value if certain criteria met

    Quote Originally Posted by zbor View Post
    arvarr, you can use this for counting unique occurances: =SUMPRODUCT((B2:B7<>"")/COUNTIF(B2:B7, B2:B7&"")).
    Your solution will give you error if there is blank value in the range.

    Solution for your problem after you adopt title name
    Hi zbor
    Thanks for your reply.
    The formula that you provided - =SUMPRODUCT((B2:B7<>"")/COUNTIF(B2:B7, B2:B7&"")) only provides me the unique occurences for the whole range.

    If i have criteria such as if I need to find the number of unique occurences for the week ending dates for Peter and David (see above).

    Thanks.

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

    Re: Get unique value if certain criteria met

    Quote Originally Posted by arvarr
    zbor...The formula that you provided ...only provides me the unique occurences for the whole range.
    zbor was simply stating that your existing unique function would fail if you had blanks - it was not posted as an answer to your actual question.

    Pre XL2007:

    =SUMPRODUCT(--($A$2:$A$7=$A10),--(MATCH($A$2:$A$7&"@"&$B$2:$B$7,$A$2:$A$7&"@"&$B$2:$B$7,0)=(ROW($A$2:$A$7)-ROW($A$2)+1)))
    copied down
    or

    =SUM((FREQUENCY(IF($A$2:$A$7=$A10,MATCH($B$2:$B$7,$B$2:$B$7,0)),ROW($B$2:$B$7)-ROW($B$2)+1)>0)+0)
    confirmed with CTRL + SHIFT + ENTER (enter alone will not suffice)
    copied down
    In addition to above - for XL2007+

    =SUMPRODUCT(($A$2:$A$7=$A10)/COUNTIFS($A$2:$A$7,$A$2:$A$7&"",$B$2:$B$7,$B$2:$B$7&""))
    copied down

  8. #8
    Registered User
    Join Date
    11-07-2010
    Location
    Australia
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: Get unique value if certain criteria met

    Hi DonkeyOte
    Thanks for the formula. Works like a charm.

    Are you able to give me an explanation of the breakdown of this formula:

    =SUMPRODUCT(--($A$2:$A$7=$A10),--(MATCH($A$2:$A$7&"@"&$B$2:$B$7,$A$2:$A$7&"@"&$B$2:$B$7,0)=(ROW($A$2:$A$7)-ROW($A$2)+1)))

    Greatly appreciated.
    Thanks.
    Last edited by DonkeyOte; 11-07-2010 at 06:23 AM. Reason: removed unnecessary quote

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

    Re: Get unique value if certain criteria met

    The first array tests that value in A2:A7 matches the name specified in A10 and returns 1 if True (0 if not)

    The second array tests to see if the MATCH of A&B of current iteration against A&B in general equals the row index of the current iteration.
    If it does then you know the combination is not a duplicate given the A&B MATCH does not appear in prior rows.
    Again where this test holds true the output is 1 (else 0)

    The product of the 2 arrays is your resulting unique count for specified name.

  10. #10
    Registered User
    Join Date
    11-07-2010
    Location
    Australia
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: Get unique value if certain criteria met

    Title changed as per request. Thanks

+ 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