+ Reply to Thread
Results 1 to 6 of 6

Modified COUNTIF but only counting unique values

  1. #1
    Forum Contributor
    Join Date
    02-09-2007
    Location
    UK
    MS-Off Ver
    2019 & 365
    Posts
    304

    Modified COUNTIF but only counting unique values

    I am looking to find a COUNTIF based formula (I think)

    Column C I have a list of account codes. For the first part of my problem, I want to focus on the ones that start with a lowercase z, but not the ones that start with z88.

    Against each time an account code appears in C, a WIP Number will be in column J.

    A WIP number is likely to appear several times in the list and it may or may not have different account numbers next to it.

    In this snapshot image example, I would expect:

    WIP 10001 to be counted once
    WIP 10008 to be counted once
    WIP 10010 to be counted once
    WIP 10011 to be counted once
    WIP 10012 to be counted once

    The account codes starting with z88 are ignored

    Any ideas on how to solve the first part of my problem before I move onto the next steps?

    Example workbook also attached if needed


    Thanks, BVG
    Attached Images Attached Images
    Attached Files Attached Files
    Last edited by Badvgood; 02-08-2021 at 04:15 PM.

  2. #2
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    43,984

    Re: Modified COUNTIF but only counting unique values

    Maybe this:

    =SUM(INDEX((CODE(LEFT($C$2:$C$1831,1))=122)*(LEFT($C$2:$C$1831,3)<>"z88")/COUNTIFS($C$2:$C$1831,$C$2:$C$1831&"",$J$2:$J$1831,$J$2:$J$1831&""),0))

    Not checked, as the sample, at 1830 rows slightly exceeds what we like to see as a sample size.... 10-20 rows maximum!! (see yellow banner, top of page).
    Attached Files Attached Files
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU.

    Temporary addition of accented to illustrate ongoing problem to the TT: L? fh?ile P?draig sona dhaoibh

  3. #3
    Forum Contributor
    Join Date
    02-09-2007
    Location
    UK
    MS-Off Ver
    2019 & 365
    Posts
    304

    Re: Modified COUNTIF but only counting unique values

    Quote Originally Posted by Glenn Kennedy View Post
    Maybe this:

    =SUM(INDEX((CODE(LEFT($C$2:$C$1831,1))=122)*(LEFT($C$2:$C$1831,3)<>"z88")/COUNTIFS($C$2:$C$1831,$C$2:$C$1831&"",$J$2:$J$1831,$J$2:$J$1831&""),0))

    Not checked, as the sample, at 1830 rows slightly exceeds what we like to see as a sample size.... 10-20 rows maximum!! (see yellow banner, top of page).
    Good evening Glenn,

    Thank you for taking a look at this for me, very much appreciated.

    Three things if you have a moment?

    1) Apologies for the larger than normal sample data, point noted.

    2) In your formula, the first part that states =122 What is that part of the formula doing

    3) I'm not sure your formula works or my methodology for checking it is wrong, which of course is entirely possible! In my very layman's testing method, I filtered the account column by z2208, copied the WIP numbers to a fresh column, then removed the duplicates. This gave me 518 unique WIP Numbers.

    Your thoughts, please?

    Kind regards BVG

  4. #4
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    43,984

    Re: Modified COUNTIF but only counting unique values

    122 is the code for a lower case Z.

    Did you filter by z22 as stated immediately above or by z88, as stated in post 1?

    I'm away for the night.

  5. #5
    Forum Contributor
    Join Date
    02-09-2007
    Location
    UK
    MS-Off Ver
    2019 & 365
    Posts
    304

    Re: Modified COUNTIF but only counting unique values

    Quote Originally Posted by Glenn Kennedy View Post
    122 is the code for a lower case Z.

    Did you filter by z22 as stated immediately above or by z88, as stated in post 1?

    I'm away for the night.
    Thanks Glenn,

    I understand on the 122 now - Never thought you could do that so I have picked up a very useful tip. Thank you.

    Spotted the z22 part, there were a few others in there that makes it all tally, your formula is spot on.

  6. #6
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    43,984

    Re: Modified COUNTIF but only counting unique values

    In response to your PM. Set up two named ranges. this will autoadjust to the length of your data. CTRL-F3 to view/edit. There are two forms here, one for account(Text) and one for WIP (a number)

    For account

    ='GSC Service Composite Tech Hrs'!$C$2:INDEX('GSC Service Composite Tech Hrs'!$C:$C,MATCH("Zzzz",'GSC Service Composite Tech Hrs'!$C:$C))

    and for WIP:

    ='GSC Service Composite Tech Hrs'!$J$2:INDEX('GSC Service Composite Tech Hrs'!$J:$J,MATCH(1E+100,'GSC Service Composite Tech Hrs'!$J:$J))

    the formula then becomes:

    =SUM(INDEX((CODE(LEFT(Account,1))=122)*(LEFT(Account,3)<>"z88")/COUNTIFS(Account,Account&"",WIP,WIP&""),0))

    which has the added advantage of being more human-readable!!
    Attached Files Attached Files

+ 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. Replies: 3
    Last Post: 04-07-2020, 05:06 AM
  2. Countif, only counting unique occurances within specified conditions
    By Butcher1 in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 02-10-2015, 02:48 PM
  3. [SOLVED] Counting unique values
    By Karroog in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 06-13-2013, 02:39 PM
  4. [SOLVED] counting unique values in col A against unique value in column B
    By greyscale in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 05-08-2013, 08:43 AM
  5. Replies: 2
    Last Post: 06-06-2012, 01:44 PM
  6. Replies: 0
    Last Post: 03-08-2012, 12:18 PM
  7. Replies: 8
    Last Post: 02-21-2012, 11:11 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