+ Reply to Thread
Results 1 to 20 of 20

How to return unique values using COUNTIFS ?

  1. #1
    Registered User
    Join Date
    05-04-2015
    Location
    NH
    MS-Off Ver
    Office 365
    Posts
    28

    How to return unique values using COUNTIFS ?

    This is a working formula, except it returns more than one login instance for a user. For example, if jdoe logged in multiple times between May 1 and May 20, it would count each login. The goal is to just count one of jdoe's logins... same deal for other users. How can I do this?

    Current formula:

    =COUNTIFS('Data-User'!$A$2:$A$500000,"ACTIVITY_LOGIN_USER",'Data-User'!$C$2:$C$500000,">="&B6,'Data-User'!$C$2:$C$500000,"<="&C6,'Data-User'!$O$2:$O$500000,"<>admin",'Data-Content'!$M$2:$M$500000,"<>*@mycompanydomain.com")

    Explanation of current formula:

    Column "O" contains usernames.

    Formula Segment Comments
    =COUNTIFS('Data-User'!$A$2:$A$500000,"ACTIVITY_LOGIN_USER", This just looks at the activity type (in this case, a login event).
    'Data-User'!$C$2:$C$500000,">="&B6,'Data-User'!$C$2:$C$500000,"<="&C6, Date range to consider.
    'Data-User'!$O$2:$O$500000,"<>admin", Do not count system admin logins.
    'Data-Content'!$M$2:$M$500000,"<>*@mycompanydomain.com") Do not count logins from my company's staff.

  2. #2
    Forum Expert gmr4evr1's Avatar
    Join Date
    11-24-2014
    Location
    Texas
    MS-Off Ver
    Office 2010 and 2007
    Posts
    3,448

    Re: How to return unique values using COUNTIFS ?

    Not sure you can do what you want with COUNTIFS, as the COUNTIFS purpose is to count the # of times a unique or specified value appears. Are you wanting to count the number of times a user logs in on a specific day, the current day/date?
    1N73LL1G3NC3 15 7H3 4B1L17Y 70 4D4P7 70 CH4NG3 - 573PH3N H4WK1NG
    You don't have to add Rep if I have helped you out (but it would be nice), but please mark the thread as SOLVED if your issue is resolved.

    Tom

  3. #3
    Forum Expert
    Join Date
    12-11-2011
    Location
    Netherlands
    MS-Off Ver
    office 365
    Posts
    3,293

    Re: How to return unique values using COUNTIFS ?

    Try the filter function or pivot table
    Willem
    English is not my native language sorry for errors
    Please correct me if I'm completely wrong

  4. #4
    Registered User
    Join Date
    12-16-2014
    Location
    Amsterdam, Nederland
    MS-Off Ver
    Excel 2013
    Posts
    71

    Re: How to return unique values using COUNTIFS ?

    HI,

    Apply something like
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    .
    Bas

    Any reputation is appreciated.

  5. #5
    Registered User
    Join Date
    05-20-2015
    Location
    PEI
    MS-Off Ver
    2013
    Posts
    9

    Re: How to return unique values using COUNTIFS ?

    Hi,

    Let me know if you were thinking of something more complex, but from what I understand all you have to do is "=if(YourLongFormula>0, True, False)". I realize this answer seems overly simple, if I misunderstood what you are trying to accomplish let me know. For what its worth, I'd probably keep the long formula you have above in a separate cell from the other if statement just to keep things more clear for the reader.

  6. #6
    Registered User
    Join Date
    05-04-2015
    Location
    NH
    MS-Off Ver
    Office 365
    Posts
    28

    Re: How to return unique values using COUNTIFS ?

    Currently, the formula counts the number of times people login in a given period of time (i.e. from June 1, 2015 to June 30, 2015), while not considering admin users or company staff users (based on email address). The value returned in test data is 1,793. However, when I took the same data and manually filtered against the login type and removed duplicate user logins, the number was much lower (394).

    I feel as if I need to filter within the COUNTIFS formula somehow, or rewrite my formula not using COUNTIFS. Any pointers would be appreciated.

    I have also tried these options, but it is not returning a numerical count value:
    IF(max(your formula)>0,1,0)
    =IF(YourLongFormula>0, True, False)

  7. #7
    Registered User
    Join Date
    05-20-2015
    Location
    PEI
    MS-Off Ver
    2013
    Posts
    9

    Re: How to return unique values using COUNTIFS ?

    Have you tried adding another column in the data that determines if the login is unique? Its hard for me to write the formula for it without seeing the data, but you would just have to have an if statement that checks if the current value exists above the current row. Then have a formula that sums all the ones in this column.

    Ignore my previous reply as I misunderstood your problem.

  8. #8
    Registered User
    Join Date
    05-20-2015
    Location
    PEI
    MS-Off Ver
    2013
    Posts
    9

    Re: How to return unique values using COUNTIFS ?

    The formula to see if the value is unique in the data set would be something like =IF(COUNTIF($D$2:D2,"="&D3)>0,0,1). This formula is in cell e3. Returns 1 if unique.

  9. #9
    Registered User
    Join Date
    05-04-2015
    Location
    NH
    MS-Off Ver
    Office 365
    Posts
    28

    Re: How to return unique values using COUNTIFS ?

    Thanks for all of your suggestions. I am not sure if I was explaining my issue as best I could so I put an example together showing the problem in context (attachment). There is a slightly modified formula in that document that drops one of the COUNTIFS exclusions for this example, and I also limited the data set to ~40 rows. The issue is highlighted in light yellow/red text.

    Thanks again,
    Curtis
    Attached Files Attached Files

  10. #10
    Valued Forum Contributor
    Join Date
    05-20-2013
    Location
    Ohio, USA
    MS-Off Ver
    Excel 2013
    Posts
    941

    Re: How to return unique values using COUNTIFS ?

    Array formula* in Report B10...
    Please Login or Register  to view this content.
    *Confirm cell entry with Ctrl+Shift+Enter

  11. #11
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: How to return unique values using COUNTIFS ?

    Another array-entered formula:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Last edited by FlameRetired; 05-21-2015 at 10:33 PM.

  12. #12
    Registered User
    Join Date
    05-04-2015
    Location
    NH
    MS-Off Ver
    Office 365
    Posts
    28

    Re: How to return unique values using COUNTIFS ?

    [Edited 11:56am May 22]

    Thanks jhren, this returns all of the unique users (first milestone I was hoping to achieve), inclusive of users with and without a @mycompanydomain.com email address in column M.

    Is there a way this query can be tweaked to only include unique users without an @mycompanydomain.com email address in column M?
    Last edited by ccarmichael; 05-22-2015 at 11:57 AM.

  13. #13
    Valued Forum Contributor
    Join Date
    05-20-2013
    Location
    Ohio, USA
    MS-Off Ver
    Excel 2013
    Posts
    941

    Re: How to return unique values using COUNTIFS ?

    Aha! Learned something myself trying to resolve your issue...

    First, the portion...
    Please Login or Register  to view this content.
    ...will have no matches because there are no email addresses with that domain in you example file. The only similar domain is @mydomain.com.

    Next, even changing to...
    Please Login or Register  to view this content.
    ...had no effect.

    Apparently, Excel does not see the * as a wildcard in that particular portion. I had to change it to...
    Please Login or Register  to view this content.
    Note that is at both locations in the formula.

  14. #14
    Valued Forum Contributor
    Join Date
    05-20-2013
    Location
    Ohio, USA
    MS-Off Ver
    Excel 2013
    Posts
    941

    Re: How to return unique values using COUNTIFS ?

    @ccarmichael

    My previous reply was to your last post before you edited (I had left it sitting on my desktop since yesterday).

    To answer your edited version, should be simply a matter of changing the "=" to "<>" (taking my last post details into consideration also).

  15. #15
    Registered User
    Join Date
    05-04-2015
    Location
    NH
    MS-Off Ver
    Office 365
    Posts
    28

    Re: How to return unique values using COUNTIFS ?

    Thanks for your reply. Just to confirm, is this what you had for the full formula?

    Please Login or Register  to view this content.

  16. #16
    Valued Forum Contributor
    Join Date
    05-20-2013
    Location
    Ohio, USA
    MS-Off Ver
    Excel 2013
    Posts
    941

    Re: How to return unique values using COUNTIFS ?

    Looks about right... but don't recall specifically. You're asking me about 3 days too late.

  17. #17
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: How to return unique values using COUNTIFS ?

    You don't need to repeat all the conditions in the bins part, try this version

    =SUM(IF(FREQUENCY(IF(('Data-User'!A2:A40="ACTIVITY_LOGIN_USER")*('Data-User'!C2:C40>=B6)*('Data-User'!C2:C40<=C6)*('Data-User'!O2:O40<>"admin")*(RIGHT('Data-User'!M2:M40,13)="@mydomain.com"),MATCH('Data-User'!H2:H40,'Data-User'!H2:H40,0)),ROW('Data-User'!A2:A40)-ROW('Data-User'!A2)+1),1))
    Audere est facere

  18. #18
    Registered User
    Join Date
    05-04-2015
    Location
    NH
    MS-Off Ver
    Office 365
    Posts
    28

    Re: How to return unique values using COUNTIFS ?

    Thanks both. If I wanted to track "New Visitors", I would want to consider a create user activity type, and a login user activity type. How could I add a second activity type into the formula? Again, to track only unique/one time logins in a given date range. I have put in bold the second activity type I would like to consider, although that does not produce accurate results.

    =SUM(IF(FREQUENCY(IF(('Data-User'!A2:A210951="ACTIVITY_LOGIN_USER"&"ACTIVITY_CREATE_USER")*('Data-User'!C2:C210951>=B6)*('Data-User'!C2:C210951<=C6)*('Data-User'!O2:O210951<>"admin")*(RIGHT('Data-User'!M2:M210951,13)<>"@mydomain.com"),MATCH('Data-User'!H2:H210951,'Data-User'!H2:H210951,0)),ROW('Data-User'!A2:A210951)-ROW('Data-User'!A2)+1),1))

  19. #19
    Registered User
    Join Date
    05-04-2015
    Location
    NH
    MS-Off Ver
    Office 365
    Posts
    28

    Re: How to return unique values using COUNTIFS ?

    @jhren,

    I've been doing some new QA work on my report and was looking at the formula you suggested. Just wanted to clarify what the formula is doing with column H? This is newly surfaced in the formula you suggested and maps to the full name field so just trying to best understand your recommendation.

    Regards,
    Curtis

  20. #20
    Valued Forum Contributor
    Join Date
    05-20-2013
    Location
    Ohio, USA
    MS-Off Ver
    Excel 2013
    Posts
    941

    Re: How to return unique values using COUNTIFS ?

    Tha MATCH function uses column H as the lookup value and lookup array. Being an array formula, it checks each cell of the lookup array for a match, and it returns the row index of the first match. This allows the FREQUENCY function to determine if there is duplicate entries in column H.

    Re your post before last, you'd have to use a [part] statement such as:
    ...IF((('Data-User'!A2:A210951="ACTIVITY_LOGIN_USER")+('Data-User'!A2:A210951="ACTIVITY_CREATE_USER"))*...
    Returns a 1 if either value; 0 otherwise.

+ 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. Countifs for Unique Values
    By lucas813 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 03-26-2015, 01:45 PM
  2. COUNTIFS unique values
    By Dan27 in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 08-14-2014, 12:13 AM
  3. countifs for unique values
    By rbenguerel in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 07-31-2014, 07:57 AM
  4. COUNTIFS with Unique Values
    By lefteegunzz in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 12-23-2013, 04:25 PM
  5. Excel 2007 : Using countifs to count unique values
    By AlexZoom in forum Excel General
    Replies: 2
    Last Post: 09-23-2010, 09:41 AM

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