+ Reply to Thread
Results 1 to 13 of 13

Thread: COUNTIF with certain criteria (No Duplicates)

  1. #1
    Registered User
    Join Date
    01-04-2012
    Location
    New York
    MS-Off Ver
    Excel 2007
    Posts
    7

    COUNTIF with certain criteria (No Duplicates)

    Hello,

    Please see the attached spreadsheet. In the spreadsheet you will see that I have 2 tabs, one summary, one detail. I am trying to create a formula on the summary page for "Total Accounts". I need to be able to count how many accounts each rep has based on the data in the detail tab. So for instance Rep 1 should have 2 accounts, while the rest should only have 1 account. There will be multiple entries for each account but for my purposes I only need to count each account once.

    Any thoughts would be greatly appreciated.

    Thanks in advance,

    Neil

    Portfolio Management Report Template.xlsx

  2. #2
    Forum Guru 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Vienna, VA, USA
    MS-Off Ver
    Excel 2003, 2007
    Posts
    2,257

    Re: COUNTIF with certain criteria (No Duplicates)

    Welcome to the Forum!

    Quote Originally Posted by Neil2470 View Post
    So for instance Rep 1 should have 2 accounts, while the rest should only have 1 account.
    That is exactly what your existing formula produces. What do you need in column B that is different than what's in column C?

    Rep Name	Total Accounts	Total Worked ( at least 1 attempt to)
    Rep 1					2
    Rep 2					1
    Rep 3					1
    Rep 4					1
    Rep 5					1
    Making the world a better place one fret at a time
    ||||||

    If someone helped you, please click on the star icon at the bottom of their post

    If your problem is solved, please update the first post:
    EDIT, Go Advanced button, set Prefix to SOLVED

    [code]
    ' Enclose code in tags like this
    [/code]

    Don't attach a screenshot
    --just attach your Excel file! It's easier and will let us experiment with your data, formulas, and code.

  3. #3
    Registered User
    Join Date
    09-26-2010
    Location
    A, A
    MS-Off Ver
    Excel 2003
    Posts
    59

    Re: COUNTIF with certain criteria (No Duplicates)

    Let me know if this helps, paste this formula in cell B2 and copy the same down.

    =COUNTIFS(Details!$A$1:$A$22,Summary!$A2,Details!$D$1:$D$22,"Engagement")

  4. #4
    Valued Forum Contributor Haseeb A's Avatar
    Join Date
    05-24-2011
    Location
    India | Kwt
    MS-Off Ver
    2007
    Posts
    1,453

    Re: COUNTIF with certain criteria (No Duplicates)

    If you are looking to count the unique Accounts based on each Rep. try this...

    =SUM(IF(FREQUENCY(IFERROR(IF(Details!A$2:A$22=A2,MATCH(Details!B$2:B$22,Details!B$2:B$22,0)),""),ROW (Details!A$2:A$22)-ROW(Details!A$2)+1),1))

    Confirmed with CTRL+SHIFT+ENTER, copy down.
    HTH; Haseeb

    If your problem is solved, please say so clearly, and mark your thread as Solved:
    Forum Rules & How to Mark a thread as SOLVED

  5. #5
    Registered User
    Join Date
    01-04-2012
    Location
    New York
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: COUNTIF with certain criteria (No Duplicates)

    Thank you all for your responses. I am trying to get exactly what Haseeb A said "unique accounts based on each rep". Haseeb you are in the ballpark, but I was not able to get your formula to work. Did you actually try it within my spreadsheet and have success?

    Thanks,

    Neil
    Last edited by Neil2470; 01-05-2012 at 02:56 PM.

  6. #6
    Registered User
    Join Date
    01-04-2012
    Location
    New York
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: COUNTIF with certain criteria (No Duplicates)

    Thank you all for your responses. I am trying to get exactly what Haseeb A said "unique accounts based on each rep". Haseeb you are in the ballpark, but I was not able to get your formula to work. Did you actually try it within my spreadsheet and have success?

    Thanks,

    Neil
    Last edited by Neil2470; 01-05-2012 at 02:56 PM.

  7. #7
    Valued Forum Contributor Haseeb A's Avatar
    Join Date
    05-24-2011
    Location
    India | Kwt
    MS-Off Ver
    2007
    Posts
    1,453

    Re: COUNTIF with certain criteria (No Duplicates)

    This is an Array Formula must hit CTRL+SHIFT+ENTER, rather than just ENTER.

    See the attached.
    Attached Files Attached Files
    HTH; Haseeb

    If your problem is solved, please say so clearly, and mark your thread as Solved:
    Forum Rules & How to Mark a thread as SOLVED

  8. #8
    Registered User
    Join Date
    01-04-2012
    Location
    New York
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: COUNTIF with certain criteria (No Duplicates)

    Quote Originally Posted by Haseeb A View Post
    This is an Array Formula must hit CTRL+SHIFT+ENTER, rather than just ENTER.

    See the attached.
    Thank you Haseeb. I am still new to array formulas but this was exactly what I needed.

  9. #9
    Forum Moderator DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Suffolk, UK
    MS-Off Ver
    2002, 2007 & 2010
    Posts
    21,423

    Re: COUNTIF with certain criteria (No Duplicates)

    FWIW, if you prefer to avoid the Array entry requirement you can use the below:

    B2:
    =SUMPRODUCT((Details!$A$2:$A$22=$A2)/COUNTIFS(Details!$A$2:$A$22,Details!$A$2:$A$22&"",Details!$B$2:$B$22,Details!$B$2:$B$22&""))
    confirmed with Enter
    copied down
    no more efficient than the Array however (arguably less so in this instance)

  10. #10
    Registered User
    Join Date
    01-04-2012
    Location
    New York
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: COUNTIF with certain criteria (No Duplicates)

    Thanks DonkeyOte, that's great as well

  11. #11
    Registered User
    Join Date
    01-04-2012
    Location
    New York
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: COUNTIF with certain criteria (No Duplicates)

    Thank you all for helping me out. I do have another problem I am trying to figure out.

    In the attached file, on the Summary tab I am trying to figure out how many times a specified account shows up in the details tab along with which rep it belongs too. For instance rep 1 has called 2 accounts at least 5 times. I need the formula to show how many Rep 1 accounts have been called at least 5 times. (So to simplify, I need a count of how many account entries show up on the details tab belonging to the specified rep) The formula should only use columns A and B.
    Attached Files Attached Files

  12. #12
    Valued Forum Contributor Haseeb A's Avatar
    Join Date
    05-24-2011
    Location
    India | Kwt
    MS-Off Ver
    2007
    Posts
    1,453

    Re: COUNTIF with certain criteria (No Duplicates)

    I am not sure I fully understood. Based on the sample,

    Rep 1 has two Accounts 'Train Inc' & 'TIDE CO'. 'Train Inc' occur 7 times, 2nd one 2 times. So if you are trying to count an account occur >=5 times for a rep, try this

    =SUM(IF(FREQUENCY(IFERROR(IF(Details!A$2:A$22=A2,MATCH(Details!B$2:B$22,Details!B$2:B$22,0)),""),ROW(Details!A$2:A$22)-ROW(Details!A$2)+1)>=5,1))
    Highlighted is the change.
    HTH; Haseeb

    If your problem is solved, please say so clearly, and mark your thread as Solved:
    Forum Rules & How to Mark a thread as SOLVED

  13. #13
    Registered User
    Join Date
    01-04-2012
    Location
    New York
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: COUNTIF with certain criteria (No Duplicates)

    Haseeb, once again you have provided exactly what I needed. Thank you!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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.2.0