+ Reply to Thread
Results 1 to 11 of 11

Count distinct values where data changes everyday

  1. #1
    Forum Contributor
    Join Date
    09-03-2012
    Location
    Newcastle
    MS-Off Ver
    Excel 2010
    Posts
    132

    Angry Count distinct values where data changes everyday

    Hi,

    I'm trying to count the distinct values within a list. My formula currently looks like this

    =IF(SUMPRODUCT(1/COUNTIF($J$17:$J$24,$J17:$J24))=SUMPRODUCT(1/COUNTIF(Resolved!$M$2:$M$53, Resolved!$M$2:$M53)), "Macro working", "Macro won't work")

    Currently it is counting the data in J17:J24 on the summary page (page where the forumla is). And it is also counting the number of unique values on the resolved tab, data M2:M53.

    Stepping in, it actually looks like:

    IF(8 = 8) [8 unique values in each list] then bring me back "Macro working". However if 8 <> 8, bring me back "Macro won't work".

    -

    The problem I am having is that the number of data in the second part of the SUMPRODUCT(1/COUNTIF( changes everyday. I need a workaround where I can simply put there M2:M500 for example, so I don't have to change the formula each time.


    So really what I want the formula to say is:

    =IF(SUMPRODUCT(1/COUNTIF($J$17:$J$24,$J17:$J24))=SUMPRODUCT(1/COUNTIF(Resolved!$M$2:$M$500, Resolved!$M$2:$M500)), "Macro working", "Macro won't work")

    Any workarounds would be great, or help!

    Many thanks
    Last edited by jonathan.haynes; 10-22-2013 at 10:20 AM.

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

    Re: Count distinct values where data changes everyday

    You can use a dynamic range.

    What type of data is in that range? Is it text? Numbers? Could be both? Something else?
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  3. #3
    Forum Contributor
    Join Date
    09-03-2012
    Location
    Newcastle
    MS-Off Ver
    Excel 2010
    Posts
    132

    Re: Count distinct values where data changes everyday

    Just text


    .

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

    Re: Count distinct values where data changes everyday

    Try this...

    Goto the Formulas tab>Define Name

    Name: MyRange (or whatever name you want to use)
    Refers to:

    =Resolved!$M$2:INDEX(Resolved!$M:$M,MATCH("zzzzz",Resolved!$M:$M))

    OK out

    Then, in your formula you would use MyRange like this:

    =IF(SUMPRODUCT(1/COUNTIF($J$17:$J$24,$J17:$J24))=SUMPRODUCT(1/COUNTIF(MyRange, MyRange)), "Macro working", "Macro won't work")

  5. #5
    Forum Contributor
    Join Date
    09-03-2012
    Location
    Newcastle
    MS-Off Ver
    Excel 2010
    Posts
    132

    Re: Count distinct values where data changes everyday

    Excellent, this works, great!! +rep.

    I understand the dynamic range part but can you please explain this below, and what exactly is it doing? what is the "zzzz"?

    =Resolved!$M$2:INDEX(Resolved!$M:$M,MATCH("zzzzz",Resolved!$M:$M))

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

    Re: Count distinct values where data changes everyday

    We're using the lookup value zzzzz to find the last (bottom-most) TEXT entry in the column.

    In Excel text has value just as numbers have value. 2 is greater than 1 and 3 is greater than 2.

    In that same manner text has value such that B is greater than A and C is greater than B. You can see this when you sort something.

    So, with that in mind...

    The lookup value zzzzz has a very high value. In this formula:

    MATCH("zzzzz",Resolved!$M:$M)

    If the lookup value zzzzz is greater than any TEXT entry in the range, MATCH will "find" the last (bottom-most) TEXT entry in the range.

    So, if your text data is "standard" text entries like names or common words then the lookup value of zzzzz is going to have a greater value and the formula works as we expect it should.

  7. #7
    Forum Contributor
    Join Date
    09-03-2012
    Location
    Newcastle
    MS-Off Ver
    Excel 2010
    Posts
    132

    Re: Count distinct values where data changes everyday

    Makes sense, thanks!

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

    Re: Count distinct values where data changes everyday

    You're welcome!

  9. #9
    Forum Contributor
    Join Date
    09-03-2012
    Location
    Newcastle
    MS-Off Ver
    Excel 2010
    Posts
    132

    Re: Count distinct values where data changes everyday

    Hi,

    Sorry to re-open but was the best way to explain.

    Everything above works, great. I am trying to do the same as above but with numbers rather than data.

    Please Login or Register  to view this content.
    The code above gives me an error message. Presume it is something to do with the "zzzzz" part as I am now looking for numbers rather than text. I've tried "000000" and "999999" but both error messages.

    Any help?!

    Thanks!

  10. #10
    Forum Contributor
    Join Date
    09-03-2012
    Location
    Newcastle
    MS-Off Ver
    Excel 2010
    Posts
    132

    Re: Count distinct values where data changes everyday

    OK i've now fixed this myself by changing MATCH to COUNT, and "zzzz" to "9999"

    Please Login or Register  to view this content.

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

    Re: Count distinct values where data changes everyday

    To define a dynamic range that contains numeric values...

    =SLA_Countdown!$A$2:INDEX(SLA_Countdown!$A:$A,MATCH(1E100,SLA_Countdown!$A:$A))

    Your formula may work but the one above is more efficient (faster to calculate).

+ 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] Count Conditional Distinct Values
    By Gos-C in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 02-10-2013, 05:41 AM
  2. [SOLVED] Count Distinct Values
    By djfatboyfats in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 11-20-2012, 07:39 AM
  3. Count of distinct (unique) values by day
    By velorian in forum Excel General
    Replies: 7
    Last Post: 12-06-2011, 05:03 PM
  4. Count distinct values with criteria
    By greencardioid in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 07-29-2008, 06:48 PM
  5. Count Distinct Values?
    By bill_morgan in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 04-26-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