+ Reply to Thread
Results 1 to 11 of 11

Count unique values with criterias

  1. #1
    Registered User
    Join Date
    04-25-2018
    Location
    MN
    MS-Off Ver
    Excel 2013
    Posts
    8

    Count unique values with criterias

    Hi,

    I am hoping someone can help me with this, I have spent too much time trying variations, looking at a ton of sites looking for something that can get me to where I need to be.

    I have three columns, each of which could contain a variety of choices and there could be duplicates

    Here is some sample data: (Titles of columns are the named ranges being used)

    Inv1Status Inv1Source Inv1Case Inv1Sub
    ----------- ------------- ------------- -----------
    Active Internet Red Joe
    Adjudicated Internet Red John
    Warrant Self Tree Yogi
    Active LE Car Han Solo
    Inactive Self House Cathy
    Inactive Self House Steve


    What I am trying to do is count how many cases are not Adjudicated or Active for each Source type.

    I have this array: =SUM(IFERROR(1/COUNTIFS(Inv1Case,Inv1Case&"",Inv1Source,N$2),0)) which gives me a correct count for the number of cases for each Source type. How do I now take it to the next level and have it exclude any Cases that have any 1 row which reflects Adjudicated or Inactive?

    The expected result from the above would be
    Internet = 0 (because row 2 has status of Adjudicated)
    LE = 1
    Self = 1 (ignores or doesn't count the case labeled House as it is Inactive)

    I cannot help to think I am close, but just cannot get the right result once I start trying to bring in the conditions from the Inv1Status column.

    Thank you in advance for your help.

    edit: Sorry, it condensed the sample data when I submitted it.
    Last edited by szc55; 04-15-2020 at 04:21 PM.

  2. #2
    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: Count unique values with criterias

    Hello szc55. Welcome to the forum.

    What is in cell N2?

    =SUM(IFERROR(1/COUNTIFS(Inv1Case,Inv1Case&"",Inv1Source,N$2),0))
    Dave

  3. #3
    Registered User
    Join Date
    04-25-2018
    Location
    MN
    MS-Off Ver
    Excel 2013
    Posts
    8

    Re: Count unique values with criterias

    Hi, thank you for the quick response. That was a reference to another cell, which contained a Source, such as "Self". That can be changed. Can disregard that cell reference.

    =SUM(IFERROR(1/COUNTIFS(Inv1Case,Inv1Case&"",Inv1Source,"Self"),0))

    Is there a way I can fix my sample data above to better space things out instead of being compressed together, just to make it look better?

    Also, thank you for the welcome. I joined a while ago and have been learning a lot, but this is one that has me stumped a little.
    Last edited by szc55; 04-15-2020 at 04:03 PM.

  4. #4
    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: Count unique values with criterias

    Yes.
    Use the text to columns feature under the Data ribbon ... Data > Data tools > Text to columns.

  5. #5
    Registered User
    Join Date
    04-25-2018
    Location
    MN
    MS-Off Ver
    Excel 2013
    Posts
    8

    Re: Count unique values with criterias

    I am trying to edit the initial post, but not seeing text to columns as an option, but will keep looking (unless you were meaning text to columns actually within excel, but I hand keyed the sample data into the post)

  6. #6
    Registered User
    Join Date
    04-25-2018
    Location
    MN
    MS-Off Ver
    Excel 2013
    Posts
    8

    Re: Count unique values with criterias

    I may have made a little breakthrough, but still not all the way there. The formula I put in above provides a unique total of Inv1Case for the choice of Inv1Source.

    =SUM(IFERROR(1/COUNTIFS(Inv1Case,Inv1Case&"",Inv1Source,"Self"),0))

    I put this together and it seems to be calculating the number of Inv1Cases for the Inv1Source of "Self" where there is at least one Inv1Sub that has an Inv1Status of Adjudicated:

    =SUMPRODUCT(((Inv1Source="Self")*(Inv1Status="Adjudicated"))/(COUNTIFS(Inv1Case,Inv1Case,Inv1Source,"Self",Inv1Status,"Adjudicated")+(Inv1Source<>"Self")+(Inv1Status<>"Adjudicated"))) then Ctrl-Shift-Enter

    With this, I now have other questions:

    1) How can I incorporate the Inv1Status of "Inactive" into this second formula (so the formula totals both statuses of Adjudicated and Inactive?)
    2) How can I subtract the second formula from the first one and have it be all one formula (would prefer to not use helper rows and not sure how to handle that subtraction in an array formula)

    I hope you experts can help me get this and again, I thank you in advance for your help and time (nothing like spending time on a puzzle during quarantine )
    Last edited by szc55; 04-16-2020 at 12:51 AM.

  7. #7
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,719

    Re: Count unique values with criterias

    There are instructions at the top of the page explaining how to attach your sample workbook.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  8. #8
    Registered User
    Join Date
    04-25-2018
    Location
    MN
    MS-Off Ver
    Excel 2013
    Posts
    8

    Re: Count unique values with criterias

    Thanks. I will do that in the morning (getting late), will probably make things a little easier.

  9. #9
    Registered User
    Join Date
    04-25-2018
    Location
    MN
    MS-Off Ver
    Excel 2013
    Posts
    8

    Re: Count unique values with criterias

    Attached is a sample worksheet. In creating this, I found that the second formula I posted does not appear to be working properly, but I did notate that within the attached.

    Edit: The second formula actually does appear to be working properly, it is totaling the unique cases for each source that reflect at least one Sub with an Adjudicated status. (sorry for any confusion)

    Thank you!


    EDIT: I tried to use the second formula twice, once for Status of Inactive and once for Status of Adjudicated, placing them into their own cells thinking I could subtract both results from the first formula. This does not work as one Inv1Case could have multiple Inv1Subs where one in Inactive and one is Adjudicated, and each formula then counts them both for the same case. When the subtraction then happens, it is subtracting two from the total when it should only be one.

    Somehow it needs to know to ignore subsequent Inactive or Adjudicated statuses once 1 is found for a particular Inv1Case.

    Is there a way to have the formula look at the Status as being an OR? Inactive or Adjudicated? Would that work?
    Attached Files Attached Files
    Last edited by szc55; 04-16-2020 at 11:36 PM.

  10. #10
    Registered User
    Join Date
    04-25-2018
    Location
    MN
    MS-Off Ver
    Excel 2013
    Posts
    8

    Re: Count unique values with criterias

    This is what I came up with to try to use as a result to subtract from the first formula listed above, but it doesn't compute properly, as it finds all Inactive and all Adjudicated. Seems like it needs to find the first of either Inactive and Adjudicated and then stop looking for more within that same Inv1Case with the Inv1Source being "self".

    =(SUMPRODUCT(((Inv1Source="Self")*(Inv1Status="Adjudicated"))/(COUNTIFS(Inv1Case,Inv1Case,Inv1Source,"Self",Inv1Status,"Adjudicated")+(Inv1Source<>"Self")+(Inv1Status<>"Adjudicated"))*(SUMPRODUCT((Inv1Source="Self")*(Inv1Status="Inactive"))/(COUNTIFS(Inv1Case,Inv1Case,Inv1Source,"Self",Inv1Status,"Inactive")+(Inv1Source<>"Self")+(Inv1Status<>"Inactive")))))

  11. #11
    Registered User
    Join Date
    04-25-2018
    Location
    MN
    MS-Off Ver
    Excel 2013
    Posts
    8

    Re: Count unique values with criterias

    May have figured it out and have it be just one formula:

    =(SUM(IFERROR(1/COUNTIFS(Inv1Case,Inv1Case&"",Inv1Source,"Self"),0)))-((SUMPRODUCT(((Inv1Source="Self")*(Inv1Status={"Adjudicated","Inactive"}))/(COUNTIFS(Inv1Case,Inv1Case,Inv1Source,"Self",Inv1Status,{"Adjudicated","Inactive"})+(Inv1Source<>"Self")+(Inv1Status<>{"Adjudicated","Inactive"}))))) then CSE

    Anyone see any issues with the formula?

+ 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 Text Values with 2 criterias/condition
    By Kim_18 in forum Excel General
    Replies: 3
    Last Post: 01-28-2020, 01:42 AM
  2. Count unique values in a table that meet one or two criterias
    By Greenyexcel in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 11-27-2019, 11:13 AM
  3. Count Unique Values based on multiple criterias
    By Dahlia in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 04-10-2016, 09:10 AM
  4. Count Unique Values based on different Criterias
    By Morwick in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 02-03-2015, 04:49 PM
  5. [SOLVED] Count unique values based multiple criterias
    By Petter120 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 11-03-2014, 03:07 AM
  6. [SOLVED] How to count unique values using multiple criterias
    By Charmymay in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 05-07-2013, 11:27 AM
  7. Finding unique values with Criterias
    By dolpphinv4 in forum Excel General
    Replies: 1
    Last Post: 04-13-2005, 10:06 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