+ Reply to Thread
Results 1 to 19 of 19

Count Unique w/ Indirect Group Criteria

  1. #1
    Forum Contributor
    Join Date
    03-24-2012
    Location
    Midwest
    MS-Off Ver
    Office 365
    Posts
    122

    Count Unique w/ Indirect Group Criteria

    I want to do a modified version of what is detailed in this ExcelJet post:

    https://exceljet.net/formula/count-u...-with-criteria

    You can see my modification of this example in my attached spreadsheet. Basically, rather than filter by a specific project name as in the ExcelJet post, I want to filter by a specific project group. A project group can contain multiple different projects. When counting the unique name values for Group1, for example, it should include both Alpha AND Omega projects in the consideration. Here are the expected return values:

    Group 1: 4 (Jim, Sandra, Carl, Sue)
    Group 2: 4 (Jim, Carl, Sue, Ayako)

    I am trying to achieve this with an INDEX/MATCH function that returns a specific named range to an INDIRECT function, but I get the N/A# error when I attempt this. Any help would be appreciated!
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    09-25-2015
    Location
    Milan Italy
    MS-Off Ver
    office 365
    Posts
    1,982

    Re: Count Unique w/ Indirect Group Criteria

    H7=SUM(IF(FREQUENCY(IF(ISNUMBER(MATCH($C$6:$C$15,INDEX(G20:H21,,MATCH(H6,G19:H19,0)),0)),MATCH(B6:B15,B6:B15,0)),ROW(B6:B15)-ROW(B6)+1),1))

    Control +shift+enter


    only office 365


    H7=COUNTA(UNIQUE(FILTER(B6:B15,ISNUMBER(MATCH(C6:C15,INDEX(G20:H21,,MATCH(H6,G19:H19,0)),0)))))

  3. #3
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,222

    Re: Count Unique w/ Indirect Group Criteria

    Please try

    =ROWS(UNIQUE(FILTER(B6:B15,ISNUMBER(MATCH(C6:C15,INDIRECT(VLOOKUP(H6,B19:C20,2,)),)))))

    or
    =ROWS(UNIQUE(FILTER(B6:B15,ISNUMBER(MATCH(C6:C15,INDEX(G20:H21,,MATCH(H6,B19:B20,)),)))))
    Attached Files Attached Files

  4. #4
    Forum Contributor
    Join Date
    03-24-2012
    Location
    Midwest
    MS-Off Ver
    Office 365
    Posts
    122

    Re: Count Unique w/ Indirect Group Criteria

    CARACALLA, I tried both of your formulas in H7 but didn't get any results? The first one returned 0 for both Group1 and Group2; the second one returned 1 for both Group1 and Group2.

    Bo_Ry, these formulas seem to work -- thanks! If I wanted to add more criteria to the filter (for example, maybe by the "Month" and "Hour" columns), where in the formulas should I make adjustments?

  5. #5
    Forum Expert
    Join Date
    09-25-2015
    Location
    Milan Italy
    MS-Off Ver
    office 365
    Posts
    1,982

    Re: Count Unique w/ Indirect Group Criteria

    Look my file . Works


    In your file Group1 in g19 and Group2 in h19 are written differently than in H6. (Group 1 and Group 2) This is the reason why the formulas don't work in yours file


    I corrected the writings in my file
    Last edited by CARACALLA; 04-07-2021 at 04:55 PM.

  6. #6
    Forum Contributor
    Join Date
    03-24-2012
    Location
    Midwest
    MS-Off Ver
    Office 365
    Posts
    122

    Re: Count Unique w/ Indirect Group Criteria

    Apologies for taking so long to get back to this -- I've been swamped at work and haven't had a chance to get back to this problem.

    CARACALLA, thanks for the revision -- it seems to be working now! As I asked to Bo_Ry, if I wanted to add more criteria to the filter (for example, maybe by the "Month" and "Hour" columns), where in the formulas should I make adjustments? In my "real" formula there are multiple variables to filter by.

  7. #7
    Forum Expert
    Join Date
    09-25-2015
    Location
    Milan Italy
    MS-Off Ver
    office 365
    Posts
    1,982

    Re: Count Unique w/ Indirect Group Criteria

    Attach the file, indicate which criteria you want to add and the corresponding results

  8. #8
    Forum Contributor
    Join Date
    03-24-2012
    Location
    Midwest
    MS-Off Ver
    Office 365
    Posts
    122

    Re: Count Unique w/ Indirect Group Criteria

    Sorry about that; see attached. In this version we need to count by group, month, and hours. The month selection is a dropdown, but the hours selection is a free-response field. The count for hours should filter records greater than the number inputted. I have included three examples of expected results in the document.
    Attached Files Attached Files

  9. #9
    Forum Expert
    Join Date
    09-25-2015
    Location
    Milan Italy
    MS-Off Ver
    office 365
    Posts
    1,982

    Re: Count Unique w/ Indirect Group Criteria

    H9=SUM(IF(FREQUENCY(IF(ISNUMBER(MATCH($C$6:$C$15,INDEX(G20:H21,,MATCH(H6,G19:H19,0)),0)),IF(D6:D15=H7,IF(E6:E15>H8,MATCH(B6:B15,B6:B15,0)))),ROW(B6:B15)-ROW(B6)+1),1))

    Control+shift+enter


    L9=IF(L$6<>"",SUM(IF(FREQUENCY(IF(ISNUMBER(MATCH($C$6:$C$15,INDEX($G$20:$H$21,,MATCH(L$6,$G$19:$H$19,0)),0)),IF($D$6:$D$15=L$7,IF($E$6:$E$15>L$8,MATCH($B$6:$B$15,$B$6:$B$15,0)))),ROW($B$6:$B$15)-ROW($B$6)+1),1)),"")

    Control+shift+enter

    copy across

  10. #10
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,222

    Re: Count Unique w/ Indirect Group Criteria

    Try at L10
    =ROWS(UNIQUE(FILTER($B$6:$B$15,ISNUMBER(MATCH($C$6:$C$15,INDEX($G$20:$H$21,,MATCH(L6,$B$19:$B$20,)),))*($D$6:$D$15=L$7)*($E$6:$E$15>L8))))
    Attached Files Attached Files

  11. #11
    Forum Contributor
    Join Date
    03-24-2012
    Location
    Midwest
    MS-Off Ver
    Office 365
    Posts
    122

    Re: Count Unique w/ Indirect Group Criteria

    Thank you both -- this is working! However, I have one question about this part of the code:

    Please Login or Register  to view this content.
    In my example both Group 1 and Group 2 had the same number of projects in the group (in this case, two each). So when you use the area G20:H21, it's an equal block. But what if the the two groups are not equal? For example, if Group 1 had four projects and Group 2 had two? Would it be okay to select the same "block" area, even though Group 2 would include two blank spaces? This is part of the reason I was trying to use named ranges with INDIRECT: the size of each group is not certain, nor necessarily equal.

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

    Re: Count Unique w/ Indirect Group Criteria

    I interpreted (or misinterpreted) your request a bit differently. I took it to mean you wanted both a list and count of unique names and you wanted to INDIRECTly reference your range names. Please let me know if I got that wrong.

    In the attached L10:N10 this for the name lists:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Then in L9:N9 for the counts:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Dave

  13. #13
    Forum Contributor
    Join Date
    03-24-2012
    Location
    Midwest
    MS-Off Ver
    Office 365
    Posts
    122

    Re: Count Unique w/ Indirect Group Criteria

    Dave, sorry for taking a few days to get back to you about this -- I've been swamped with work. While I don't need a list (in fact, I can't generate a separate list when seeking the count), I do like how you have utilized the two indirect group names in your solution. That offers some flexibility I wanted. Is there some way to combine the count formula in L9:N9 with the formulas in L10:N10, such that it only shows the count?

  14. #14
    Forum Expert
    Join Date
    09-25-2015
    Location
    Milan Italy
    MS-Off Ver
    office 365
    Posts
    1,982

    Re: Count Unique w/ Indirect Group Criteria

    attach a file for problem post 11

  15. #15
    Forum Contributor
    Join Date
    03-24-2012
    Location
    Midwest
    MS-Off Ver
    Office 365
    Posts
    122

    Re: Count Unique w/ Indirect Group Criteria

    Apologies; see attached. Notice that Group 1 has two projects, while Group 2 has three. I adjusted the expected results accordingly.
    Attached Files Attached Files

  16. #16
    Forum Expert
    Join Date
    09-25-2015
    Location
    Milan Italy
    MS-Off Ver
    office 365
    Posts
    1,982

    Re: Count Unique w/ Indirect Group Criteria

    Group Group 2
    Month July
    Hours > 2 is 4 not 5 because Sue is double
    Last edited by CARACALLA; 04-20-2021 at 07:02 PM.

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

    Re: Count Unique w/ Indirect Group Criteria

    Quote Originally Posted by hysterical.useless View Post
    Dave, ..... , I do like how you have utilized the two indirect group names in your solution. That offers some flexibility I wanted. Is there some way to combine the count formula in L9:N9 with the formulas in L10:N10, such that it only shows the count?
    Yes. Replace the formula in L9:N9 with this.
    Formula: copy to clipboard
    Please Login or Register  to view this content.

  18. #18
    Forum Contributor
    Join Date
    03-24-2012
    Location
    Midwest
    MS-Off Ver
    Office 365
    Posts
    122

    Re: Count Unique w/ Indirect Group Criteria

    Dave, I feel dumb for not having thought of that, ha. I thought the UNIQUE formula couldn't be wrapped without spillover effects, but I was wrong. Should have tried before asking; sorry.

    CARACALLA, thanks for your continued help with this. I ended up adapting your solution successfully to my "real" sheet.

    Dave, your solution worked great in the example form I provided but for some reason could not get it working on my "real" sheet. The UNIQUE formula kept on generating a VALUE error. But I don't think it's a problem with how you solved it in the example sheet.

    Thanks everyone for your help with this! I think I'll marked this solved now.

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

    Re: Count Unique w/ Indirect Group Criteria

    hysterical.useless without seeing your "real" sheet (along with malfunctioning formula) I wouldn't know what to advise.

    Are your named ranges the same? The use of the INDIRECT is unusual. INDIRECT can be a bit "fickle" as well as volatile. I seldom use it, but I would start by examining those parts.

+ 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. Count of Age group with unique customers
    By Rushendra in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-23-2016, 01:21 AM
  2. [SOLVED] Count unique entries based off unique criteria in another column
    By hambly in forum Excel Formulas & Functions
    Replies: 15
    Last Post: 06-11-2014, 03:33 PM
  3. [SOLVED] Unique Count In Group SubTotal
    By goss in forum Excel Charting & Pivots
    Replies: 5
    Last Post: 04-17-2014, 12:42 PM
  4. [SOLVED] potential indirect countif: trying to count unique values giving same responses
    By j.farr3ll in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 11-14-2013, 08:00 AM
  5. Count of unique stores in a group
    By ZealotAssasin in forum Excel General
    Replies: 4
    Last Post: 05-16-2012, 02:10 PM
  6. Count criteria in group entered in one cell
    By PBG4 in forum Excel General
    Replies: 4
    Last Post: 04-20-2010, 10:47 PM
  7. Count Unique within Group
    By Krazy Kasper in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-23-2008, 08:56 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