+ Reply to Thread
Results 1 to 7 of 7

counting unique values based on a condition with autofiltering

  1. #1
    Registered User
    Join Date
    03-19-2014
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2010
    Posts
    3

    counting unique values based on a condition with autofiltering

    Hi all,

    Like all, apologies if this may have been answered already... if so please point me to the right thread...

    I have a column that contains unique values and I am able to count the total amount of unique entries that updates when an autofilter is used. The formula I have used is:

    =SUM(IF(FREQUENCY(IF(SUBTOTAL(3,OFFSET(M32,ROW(M32:M6294)-ROW(M32),,1)),
    IF(M32:M6294<>"",MATCH("~"&M32:M6294,M32:M6294&"",0))),ROW(M32:M6294)-ROW(M32)+1),1))

    My question is, how can I further restrict this to only provide unique values if the condition in say cell I7 appears in column "S"?

    I am using excel 2010 if this helps?

    Thanks heaps

    Sam

  2. #2
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: counting unique values based on a condition with autofiltering

    For looking for that condition as a part of each cell, I'd inject ISNUMBER(SEARCH(I7,range)) into an additional IF layer.

    Otherwise, a simple = would do.

    Without seeing your data, it's difficult to say for sure but it might look something like this:

    =SUM(IF(FREQUENCY(IF(SUBTOTAL(3,OFFSET(M32,ROW(M32:M6294)-ROW(M32),,1)),
    IF(M32:M6294<>"", IF(isnumber(search(I7,S32:S6294)) ,MATCH("~"&M32:M6294,M32:M6294&"",0))),ROW(M32:M6294)-ROW(M32)+1),1)))

    =SUM(IF(FREQUENCY(IF(SUBTOTAL(3,OFFSET(M32,ROW(M32:M6294)-ROW(M32),,1)),
    IF(M32:M6294<>"", IF(S32:S6294=I7 ,MATCH("~"&M32:M6294,M32:M6294&"",0))),ROW(M32:M6294)-ROW(M32)+1),1)))
    Make Mom proud: Add to my reputation if I helped out!

    Make the Moderators happy: Mark the Thread as Solved if your question was answered!

  3. #3
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: counting unique values based on a condition with autofiltering

    Are there empty cells within the range M32:M6294?

    What kind of data is in that range? Can you post a few examples?

    What's in I7? You said:

    if the condition in say cell I7 appears in column "S"?
    don't you mean:

    if the value/entry in say cell I7 appears in column "S"?
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  4. #4
    Registered User
    Join Date
    03-19-2014
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: counting unique values based on a condition with autofiltering

    Hi @daffodil11 and @Tony Valko

    One thing I should have mentioned is that I enter this formula as an array (CNTRL + SHIFT + ENTER).

    I have created a "clean" version of the data file and attached it here.

    Cell B8 gives me the total number of groups in the range C11:C79. This updates perfectly when you apply filters in header row 10

    What I would like to see is a total number groups linked to a specific condition, in this case the ABC segment. So in B3 I would like to see the number of unique groups that are in segment "A".

    I hope this helps a little more?

    Thanks heaps

    Sam
    Attached Files Attached Files

  5. #5
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: counting unique values based on a condition with autofiltering

    Try this...

    Array entered** in B3 and copied down:

    =SUM(IF(FREQUENCY(IF(SUBTOTAL(3,OFFSET(C$11,ROW(C$11:C$79)-ROW(C$11),0)),IF(C$11:C$79<>"",IF(D$11:D$79=A3,MATCH(C$11:C$79,C$11:C$79,0)))),ROW(C$11:C$79)-ROW(C$11)+1),1))

    You can reduce the array formula** in B8 to:

    =SUM(IF(FREQUENCY(IF(SUBTOTAL(3,OFFSET(C11,ROW(C11:C79)-ROW(C11),0)),IF(C11:C79<>"",MATCH(C11:C79,C11:C79,0))),ROW(C11:C79)-ROW(C11)+1),1))

    ** array formulas need to be entered using the key
    combination of CTRL,SHIFT,ENTER (not just ENTER).
    Hold down both the CTRL key and the SHIFT key
    then hit ENTER.

  6. #6
    Registered User
    Join Date
    03-19-2014
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: counting unique values based on a condition with autofiltering

    Quote Originally Posted by Tony Valko View Post
    Try this...

    Array entered** in B3 and copied down:

    =SUM(IF(FREQUENCY(IF(SUBTOTAL(3,OFFSET(C$11,ROW(C$11:C$79)-ROW(C$11),0)),IF(C$11:C$79<>"",IF(D$11:D$79=A3,MATCH(C$11:C$79,C$11:C$79,0)))),ROW(C$11:C$79)-ROW(C$11)+1),1))

    You can reduce the array formula** in B8 to:

    =SUM(IF(FREQUENCY(IF(SUBTOTAL(3,OFFSET(C11,ROW(C11:C79)-ROW(C11),0)),IF(C11:C79<>"",MATCH(C11:C79,C11:C79,0))),ROW(C11:C79)-ROW(C11)+1),1))

    ** array formulas need to be entered using the key
    combination of CTRL,SHIFT,ENTER (not just ENTER).
    Hold down both the CTRL key and the SHIFT key
    then hit ENTER.
    Thanks Tony - works a treat!!

  7. #7
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: counting unique values based on a condition with autofiltering

    You're welcome. Thanks for the feedback!


    If your question has been solved please mark the thread as being solved.

    In the menu bar above the very first post select Thread Tools, then select Mark this thread as solved.

+ 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 unique values based on condition
    By pradeev in forum Excel General
    Replies: 4
    Last Post: 06-12-2012, 10:43 AM
  2. Counting Unique Values based on several criteria
    By GowHow in forum Excel General
    Replies: 2
    Last Post: 04-25-2012, 10:16 PM
  3. Replies: 0
    Last Post: 03-08-2012, 12:18 PM
  4. [SOLVED] Counting unique entries based on given condition
    By Hari in forum Excel General
    Replies: 9
    Last Post: 06-06-2006, 03:40 PM
  5. Counting unique items in a list based on a condition
    By George Lynch in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-11-2005, 09:06 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