+ Reply to Thread
Results 1 to 14 of 14

Count number of unique names in a filtered list (non array)

  1. #1
    Registered User
    Join Date
    01-21-2013
    Location
    Birmingham, England
    MS-Off Ver
    Excel 2003
    Posts
    20

    Count number of unique names in a filtered list (non array)

    Hi

    I have a list of names in column B2:B1394, along with other data in adjacent columns.

    After filtering the data from the adjacent columns, how do I then return the number of unique names in column B (ideally using a non-array formula).

    I have previously used:
    =SUMPRODUCT((B2:B1394<>"")/COUNTIF(B2:B1394,B2:B1394))
    But this does not work once the list is filtered.

    I am using Excel 2003 if that makes a difference.

    Many thanks in advance.

  2. #2
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,648

    Re: Count number of unique names in a filtered list (non array)

    See if this solves your problem......

    Please Login or Register  to view this content.
    Regards
    sktneer


    Treat people the way you want to be treated. Talk to people the way you want to be talked to.
    Respect is earned NOT given.

  3. #3
    Registered User
    Join Date
    01-21-2013
    Location
    Birmingham, England
    MS-Off Ver
    Excel 2003
    Posts
    20

    Re: Count number of unique names in a filtered list (non array)

    Thanks sktneer but unfortunately this still only gives me the unique total of everything in cells B2:B1394, even after the filters are applied.

    Any other ideas???

  4. #4
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,648

    Re: Count number of unique names in a filtered list (non array)

    Please upload a sample workbook along with the desired output to let us know exactly about your requirement.

  5. #5
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Count number of unique names in a filtered list (non array)

    Hi,

    Try this array formula**:

    =SUM(--(FREQUENCY(IF(SUBTOTAL(3,OFFSET(B2,ROW(B2:B1394)-MIN(ROW(B2:B1394)),,,)),MATCH(B2:B1394,B2:B1394,0)),ROW(B2:B1394)-MIN(ROW(B2:B1394))+1)>0))

    Regards


    **Array formulas are not entered in the same way as 'standard' formulas. Instead of pressing just ENTER, you first hold down CTRL and SHIFT, and only then press ENTER. If you've done it correctly, you'll notice Excel puts curly brackets {} around the formula (though do not attempt to manually insert these yourself).
    Click * below if this answer helped

    Advanced Excel Techniques: http://excelxor.com/

  6. #6
    Registered User
    Join Date
    01-21-2013
    Location
    Birmingham, England
    MS-Off Ver
    Excel 2003
    Posts
    20

    Re: Count number of unique names in a filtered list (non array)

    Sample document attached, basically if I filter "Job Description" by "Bus Driver" I want the total of column E (red) to say 3 (as there are 2 F's).

    The current formula is right when un-filtered, but does not change when the filter is applied.

    Thanks
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    01-21-2013
    Location
    Birmingham, England
    MS-Off Ver
    Excel 2003
    Posts
    20

    Re: Count number of unique names in a filtered list (non array)

    Hi XOR LX

    The array formula works great (thanks) but was hoping for a non-array solution it possible?

  8. #8
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Count number of unique names in a filtered list (non array)

    That might be tricky. May I ask what your objection to the array version is?

  9. #9
    Registered User
    Join Date
    01-21-2013
    Location
    Birmingham, England
    MS-Off Ver
    Excel 2003
    Posts
    20

    Re: Count number of unique names in a filtered list (non array)

    Yes, I probably should have just explained the whole situation in the first place!!!

    Basically I have a large volume of employee data on one sheet which includes name, workplace, grade, salary, etc... I am trying to create a summary on a different sheet that automatically populates the number of people at each grade by workplace.

    I have been successfully using the following formula on the summary sheet to lookup all the employees on a particular grade (cell ref: C$3), working at a particular site (cell ref B5), and return the total of the filtered data in column P:

    =+SUMPRODUCT(('Data'!$N$2:$N$1394='Summary'!$B5)*('Data'!$L$2:$L$1394='Summary'!C$3)*('Data'!$P$2:$P$1394))

    Next to this I wanted to show the actual number of people (headcount) bearing in mind that some employees will be on the filtered list more than once. I therefore tried the array formula you suggested as follows:

    =+SUMPRODUCT(('Data'!$N$2:$N$1394='Summary'!$B5)*('Data'!$L$2:$L$1394='Summary'!C$3)*(SUM(--(FREQUENCY(IF(SUBTOTAL(3,OFFSET('Data'!$B$2,ROW('Data'!$B$2:$B$1394)-MIN(ROW('Data'!$B$2:$B$1394)),,,)),MATCH('Data'!$B$2:$B$1394,'Data'!$B$2:$B$1394,0)),ROW('Data'!$B$2:$B$1394)-MIN(ROW('Data'!$B$2:$B$1394))+1)>0))))

    Unfortunatley this does not remove any duplicates and basically just tells me how many lines (including duplicates) have been filtered. I thought this may be because I am using an array formula within a normal formula, given that the array formula works on its own when used on the data sheet itself. Hence I was asking for a non-array version, but I'm sure there's a better way anyhow!

    Hope this kind of makes sense and thanks for all your help so far.

  10. #10
    Registered User
    Join Date
    01-21-2013
    Location
    Birmingham, England
    MS-Off Ver
    Excel 2003
    Posts
    20

    Re: Count number of unique names in a filtered list (non array)

    I attach a second example which should show what I mean...

    The array formula is in cell G19 (red figure). When you filter "Grade" to "1" and "Workplace" to "Wales" G19 changes to "2" - this is correct as "E" appears twice in the "name" column.

    So my question is, how do I get the same result to show in the "summary" sheet cell "C5" as this currently returns "3" counting all the lines including the duplicate "E".

    Thanks
    Attached Files Attached Files

  11. #11
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Count number of unique names in a filtered list (non array)

    I'm confused. Firstly, you say you were "successfully using":

    =SUMPRODUCT(('Data'!$N$2:$N$1394='Summary'!$B5)*('Data'!$L$2:$L$1394='Summary'!C$3)*('Data'!$P$2:$P$1394))

    to "return the total of the filtered data", though as it stands this formula will not be in any way affected by filtering.

    Secondly, there is no reference in this formula to a column B in the 'Data' tab, but this is precisely what you have added using my formula as the column for counting unique, filtered returns.

    In which column are the employees, then?

    I think it's time that you uploaded an actual workbook. Obviously replace any confidential/sensitive information with dummy data if necessary.

    Regards
    Last edited by XOR LX; 01-30-2014 at 01:18 PM.

  12. #12
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Count number of unique names in a filtered list (non array)

    Just seen your attachment. Thanks. Still not sure, but I think you mean (in C5, and again, array-entered):

    =SUM(--(FREQUENCY(IF((Data!$E$2:$E$18=Summary!$A5)*(Data!$D$2:$D$18=Summary!C$2),IF(SUBTOTAL(3,OFFSET(Data!$B$2,ROW(Data!$B$2:$B$18)-MIN(ROW(Data!$B$2:$B$18)),,,)),MATCH(Data!$B$2:$B$18,Data!$B$2:$B$18,0))),ROW(Data!$B$2:$B$18)-MIN(ROW(Data!$B$2:$B$18))+1)>0))

    Regards

  13. #13
    Registered User
    Join Date
    01-21-2013
    Location
    Birmingham, England
    MS-Off Ver
    Excel 2003
    Posts
    20

    Re: Count number of unique names in a filtered list (non array)

    That seems to have done the trick, thanks for all your help.

  14. #14
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Count number of unique names in a filtered list (non array)

    You're welcome.

+ 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] Looking to create a list of unique names that match criteria without using an array
    By john dalton in forum Excel Formulas & Functions
    Replies: 14
    Last Post: 03-28-2014, 04:28 AM
  2. [SOLVED] Count unique names only, not the number of times it appears
    By amyp22x3 in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 04-04-2013, 01:32 PM
  3. [SOLVED] Count unique names only, not the number of times it appears
    By amyp22x3 in forum Excel General
    Replies: 7
    Last Post: 04-04-2013, 11:37 AM
  4. Count Number of Unique Names in a List
    By acewriter63 in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 10-09-2012, 09:12 AM
  5. [SOLVED] Array formula, returning unique list of names w/ vlookup
    By BROWN_RY in forum Excel General
    Replies: 0
    Last Post: 03-29-2012, 04:31 PM

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