+ Reply to Thread
Results 1 to 51 of 51

Counting Unique Values

  1. #1
    Bob Phillips
    Guest

    Re: Counting Unique Values

    =SUMPRODUCT((A1:A20=1)/COUNTIF(B1:B20,B1:B20&""))

    --

    HTH

    RP
    (remove nothere from the email address if mailing direct)


    "carl" <carl@discussions.microsoft.com> wrote in message
    news:7CEF6B1D-B90D-49E1-91F5-448278DF6DE4@microsoft.com...
    > I have my data like so:
    >
    > ColA ColB
    > 1 A
    > 1 B
    > 2 A
    > 2 B
    > 1 C
    > 1 D
    >
    > Is there a way yo count the number of unique values in ColB if ColA value
    > equals 1.
    >
    > So in the above, the answer would be 4.
    >
    > Thank you in advance.
    >




  2. #2
    Aladin Akyurek
    Guest

    Re: Counting Unique Values

    The option (b) can be shorter:

    =SUMPRODUCT(--(A2:A15="Include"),--(B2:B15<>""),--((MATCH(A2:A15&"#"&B2:B15,A2:A15&"#"&B2:B15,0)=ROW(A2:A15)-ROW(A2)+1)))

    I wonder if

    =SUMPRODUCT(--(A2:A15="Include"),--(B2:B15<>""),--ISNUMBER(MATCH(MATCH(A2:A15&"#"&B2:B15,A2:A15&"#"&B2:B15,0),ROW(A2:A15)-ROW(A2)+1,0)))

    would calculate faster.

    Aladin Akyurek wrote:
    > Two options...
    >
    > {a) If you have the latest version of Longre's morefunc.xll add-in:
    >
    > =COUNTDIFF(IF(A2:A15="Include",IF(B2:B15<>"",B2:B15)),FALSE,FALSE)
    >
    > which must be confirmed with control+shift+enter, not just with enter.
    >
    > (b) With built-in functions:
    >
    > =SUMPRODUCT(--(A2:A15="Include"),--(B2:B15<>""),--((MATCH(A2:A15&"#"&B2:B15,A2:A15&"#"&B2:B15,0)=ROW(INDEX(A2:A15,0,0))-ROW(A2)+1)))
    >
    >
    > K wrote:
    >
    >> Thanks so much for this string, it was exactly the info I needed...
    >> But - I tried this with my data (4000 rows, one column with values
    >> "Include" and "Exclude" that is the criteria for counting the unique
    >> text values in the second column), and ended up with a formula result
    >> 1043.4907. Do I round up or down???
    >>
    >> =SUMPRODUCT((A2:A3964="Include)/COUNTIF(D2:D3964, D2:D3964&""))
    >>
    >> I don't understand how the formula works or I would troubleshoot it
    >> myself
    >> "Bob Phillips" wrote:
    >>
    >>
    >>> =SUMPRODUCT((A1:A20=1)/COUNTIF(B1:B20,B1:B20&""))
    >>>
    >>> --
    >>>
    >>> HTH
    >>>
    >>> RP
    >>> (remove nothere from the email address if mailing direct)
    >>>
    >>>
    >>> "carl" <carl@discussions.microsoft.com> wrote in message
    >>> news:7CEF6B1D-B90D-49E1-91F5-448278DF6DE4@microsoft.com...
    >>>
    >>>> I have my data like so:
    >>>>
    >>>> ColA ColB
    >>>> 1 A
    >>>> 1 B
    >>>> 2 A
    >>>> 2 B
    >>>> 1 C
    >>>> 1 D
    >>>>
    >>>> Is there a way yo count the number of unique values in ColB if ColA
    >>>> value
    >>>> equals 1.
    >>>>
    >>>> So in the above, the answer would be 4.
    >>>>
    >>>> Thank you in advance.
    >>>>
    >>>
    >>>
    >>>

    >


    --

    [1] The SumProduct function should implicitly coerce the truth values to
    their Excel numeric equivalents.
    [2] The lookup functions should have an optional argument for the return
    value, defaulting to #N/A in its absence.

  3. #3
    Aladin Akyurek
    Guest

    Re: Counting Unique Values

    Two options...

    {a) If you have the latest version of Longre's morefunc.xll add-in:

    =COUNTDIFF(IF(A2:A15="Include",IF(B2:B15<>"",B2:B15)),FALSE,FALSE)

    which must be confirmed with control+shift+enter, not just with enter.

    (b) With built-in functions:

    =SUMPRODUCT(--(A2:A15="Include"),--(B2:B15<>""),--((MATCH(A2:A15&"#"&B2:B15,A2:A15&"#"&B2:B15,0)=ROW(INDEX(A2:A15,0,0))-ROW(A2)+1)))

    K wrote:
    > Thanks so much for this string, it was exactly the info I needed...
    >
    > But - I tried this with my data (4000 rows, one column with values "Include"
    > and "Exclude" that is the criteria for counting the unique text values in the
    > second column), and ended up with a formula result 1043.4907. Do I round up
    > or down???
    >
    > =SUMPRODUCT((A2:A3964="Include)/COUNTIF(D2:D3964, D2:D3964&""))
    >
    > I don't understand how the formula works or I would troubleshoot it myself
    >
    > "Bob Phillips" wrote:
    >
    >
    >>=SUMPRODUCT((A1:A20=1)/COUNTIF(B1:B20,B1:B20&""))
    >>
    >>--
    >>
    >>HTH
    >>
    >>RP
    >>(remove nothere from the email address if mailing direct)
    >>
    >>
    >>"carl" <carl@discussions.microsoft.com> wrote in message
    >>news:7CEF6B1D-B90D-49E1-91F5-448278DF6DE4@microsoft.com...
    >>
    >>>I have my data like so:
    >>>
    >>>ColA ColB
    >>>1 A
    >>>1 B
    >>>2 A
    >>>2 B
    >>>1 C
    >>>1 D
    >>>
    >>>Is there a way yo count the number of unique values in ColB if ColA value
    >>>equals 1.
    >>>
    >>>So in the above, the answer would be 4.
    >>>
    >>>Thank you in advance.
    >>>

    >>
    >>
    >>


    --

    [1] The SumProduct function should implicitly coerce the truth values to
    their Excel numeric equivalents.
    [2] The lookup functions should have an optional argument for the return
    value, defaulting to #N/A in its absence.

  4. #4
    K
    Guest

    Re: Counting Unique Values

    Thanks so much for this string, it was exactly the info I needed...

    But - I tried this with my data (4000 rows, one column with values "Include"
    and "Exclude" that is the criteria for counting the unique text values in the
    second column), and ended up with a formula result 1043.4907. Do I round up
    or down???

    =SUMPRODUCT((A2:A3964="Include)/COUNTIF(D2:D3964, D2:D3964&""))

    I don't understand how the formula works or I would troubleshoot it myself

    "Bob Phillips" wrote:

    > =SUMPRODUCT((A1:A20=1)/COUNTIF(B1:B20,B1:B20&""))
    >
    > --
    >
    > HTH
    >
    > RP
    > (remove nothere from the email address if mailing direct)
    >
    >
    > "carl" <carl@discussions.microsoft.com> wrote in message
    > news:7CEF6B1D-B90D-49E1-91F5-448278DF6DE4@microsoft.com...
    > > I have my data like so:
    > >
    > > ColA ColB
    > > 1 A
    > > 1 B
    > > 2 A
    > > 2 B
    > > 1 C
    > > 1 D
    > >
    > > Is there a way yo count the number of unique values in ColB if ColA value
    > > equals 1.
    > >
    > > So in the above, the answer would be 4.
    > >
    > > Thank you in advance.
    > >

    >
    >
    >


  5. #5
    Bob Phillips
    Guest

    Re: Counting Unique Values


    "Aladin Akyurek" <akyurek@xs4all.nl> wrote in message
    news:42af48c4$0$95844$e4fe514c@news.xs4all.nl...
    > Bob Phillips wrote:
    > > =SUMPRODUCT((A1:A20=1)/COUNTIF(B1:B20,B1:B20&""))
    > >

    >
    > Did you test that? Here is a sample:


    Of course I did, and it worked with data as presented. I didn't test with
    gaps in column B, but that is simply corrected if necessary.



  6. #6
    Aladin Akyurek
    Guest

    Re: Counting Unique Values

    Bob Phillips wrote:
    > =SUMPRODUCT((A1:A20=1)/COUNTIF(B1:B20,B1:B20&""))
    >


    Did you test that? Here is a sample:

    {1,"A";0,"B";2,"A";2,"B";1,0;1,"D"}

    where 0 stands for empty cells. Formula blanks [ ="" ] would have the
    same effect.

    --

    [1] The SumProduct function should implicitly coerce the truth values to
    their Excel numeric equivalents.
    [2] The lookup functions should have an optional argument for the return
    value, defaulting to #N/A in its absence.

  7. #7
    Aladin Akyurek
    Guest

    Re: Counting Unique Values

    carl wrote:
    > I have my data like so:
    >
    > ColA ColB
    > 1 A
    > 1 B
    > 2 A
    > 2 B
    > 1 C
    > 1 D
    >
    > Is there a way yo count the number of unique values in ColB if ColA value
    > equals 1.
    >
    > So in the above, the answer would be 4.
    >
    > Thank you in advance.
    >


    If you have Longre's morefunc.xll add-in:

    =COUNTDIFF(IF($A$2:$A$7=1,$B$2:$B$7,0),FALSE,0)

    which you need to confirm with control+shift+enter.

    Or:

    =COUNT(1/FREQUENCY(IF((A2:A7=1)*(B2:B7<>""),MATCH(B2:B7,B2:B7,0)),ROW(INDEX(B2:B7,0,0))-ROW(B2)+1))

    which must be confirmed with control+shift+enter.
    --

    [1] The SumProduct function should implicitly coerce the truth values to
    their Excel numeric equivalents.
    [2] The lookup functions should have an optional argument for the return
    value, defaulting to #N/A in its absence.

  8. #8
    Domenic
    Guest

    Re: Counting Unique Values

    Try...

    =SUM(IF(FREQUENCY(IF((A1:A6=1)*(B1:B6<>""),MATCH(B1:B6,B1:B6,0)),ROW(INDE
    X(B1:B6,0,0))-ROW(B1)+1)>0,1,0))

    OR

    =COUNT(1/FREQUENCY(IF((A1:A6=1)*(B1:B6<>""),MATCH(B1:B6,B1:B6,0)),ROW(IND
    EX(B1:B6,0,0))-ROW(B1)+1))

    Both these formulas need to be confirmed with CONTROL+SHIFT+ENTER, not
    just ENTER.

    Hope this helps!

    In article <7CEF6B1D-B90D-49E1-91F5-448278DF6DE4@microsoft.com>,
    "carl" <carl@discussions.microsoft.com> wrote:

    > I have my data like so:
    >
    > ColA ColB
    > 1 A
    > 1 B
    > 2 A
    > 2 B
    > 1 C
    > 1 D
    >
    > Is there a way yo count the number of unique values in ColB if ColA value
    > equals 1.
    >
    > So in the above, the answer would be 4.
    >
    > Thank you in advance.


  9. #9
    RagDyer
    Guest

    Re: Counting Unique Values

    And ... if Column B should happen to contain blanks, you could try this:

    =SUMPRODUCT((A1:A20=1)/COUNTIF(B1:B20,B1:B20&"")*(B1:B20<>""))
    --
    HTH,

    RD
    ==============================================
    Please keep all correspondence within the Group, so all may benefit!
    ==============================================



    "Bob Phillips" <bob.phillips@notheretiscali.co.uk> wrote in message
    news:OC7LU$RcFHA.1392@TK2MSFTNGP14.phx.gbl...
    > =SUMPRODUCT((A1:A20=1)/COUNTIF(B1:B20,B1:B20&""))
    >
    > --
    >
    > HTH
    >
    > RP
    > (remove nothere from the email address if mailing direct)
    >
    >
    > "carl" <carl@discussions.microsoft.com> wrote in message
    > news:7CEF6B1D-B90D-49E1-91F5-448278DF6DE4@microsoft.com...
    > > I have my data like so:
    > >
    > > ColA ColB
    > > 1 A
    > > 1 B
    > > 2 A
    > > 2 B
    > > 1 C
    > > 1 D
    > >
    > > Is there a way yo count the number of unique values in ColB if ColA

    value
    > > equals 1.
    > >
    > > So in the above, the answer would be 4.
    > >
    > > Thank you in advance.
    > >

    >
    >



  10. #10
    Aladin Akyurek
    Guest

    Re: Counting Unique Values

    The option (b) can be shorter:

    =SUMPRODUCT(--(A2:A15="Include"),--(B2:B15<>""),--((MATCH(A2:A15&"#"&B2:B15,A2:A15&"#"&B2:B15,0)=ROW(A2:A15)-ROW(A2)+1)))

    I wonder if

    =SUMPRODUCT(--(A2:A15="Include"),--(B2:B15<>""),--ISNUMBER(MATCH(MATCH(A2:A15&"#"&B2:B15,A2:A15&"#"&B2:B15,0),ROW(A2:A15)-ROW(A2)+1,0)))

    would calculate faster.

    Aladin Akyurek wrote:
    > Two options...
    >
    > {a) If you have the latest version of Longre's morefunc.xll add-in:
    >
    > =COUNTDIFF(IF(A2:A15="Include",IF(B2:B15<>"",B2:B15)),FALSE,FALSE)
    >
    > which must be confirmed with control+shift+enter, not just with enter.
    >
    > (b) With built-in functions:
    >
    > =SUMPRODUCT(--(A2:A15="Include"),--(B2:B15<>""),--((MATCH(A2:A15&"#"&B2:B15,A2:A15&"#"&B2:B15,0)=ROW(INDEX(A2:A15,0,0))-ROW(A2)+1)))
    >
    >
    > K wrote:
    >
    >> Thanks so much for this string, it was exactly the info I needed...
    >> But - I tried this with my data (4000 rows, one column with values
    >> "Include" and "Exclude" that is the criteria for counting the unique
    >> text values in the second column), and ended up with a formula result
    >> 1043.4907. Do I round up or down???
    >>
    >> =SUMPRODUCT((A2:A3964="Include)/COUNTIF(D2:D3964, D2:D3964&""))
    >>
    >> I don't understand how the formula works or I would troubleshoot it
    >> myself
    >> "Bob Phillips" wrote:
    >>
    >>
    >>> =SUMPRODUCT((A1:A20=1)/COUNTIF(B1:B20,B1:B20&""))
    >>>
    >>> --
    >>>
    >>> HTH
    >>>
    >>> RP
    >>> (remove nothere from the email address if mailing direct)
    >>>
    >>>
    >>> "carl" <carl@discussions.microsoft.com> wrote in message
    >>> news:7CEF6B1D-B90D-49E1-91F5-448278DF6DE4@microsoft.com...
    >>>
    >>>> I have my data like so:
    >>>>
    >>>> ColA ColB
    >>>> 1 A
    >>>> 1 B
    >>>> 2 A
    >>>> 2 B
    >>>> 1 C
    >>>> 1 D
    >>>>
    >>>> Is there a way yo count the number of unique values in ColB if ColA
    >>>> value
    >>>> equals 1.
    >>>>
    >>>> So in the above, the answer would be 4.
    >>>>
    >>>> Thank you in advance.
    >>>>
    >>>
    >>>
    >>>

    >


    --

    [1] The SumProduct function should implicitly coerce the truth values to
    their Excel numeric equivalents.
    [2] The lookup functions should have an optional argument for the return
    value, defaulting to #N/A in its absence.

  11. #11
    Aladin Akyurek
    Guest

    Re: Counting Unique Values

    Two options...

    {a) If you have the latest version of Longre's morefunc.xll add-in:

    =COUNTDIFF(IF(A2:A15="Include",IF(B2:B15<>"",B2:B15)),FALSE,FALSE)

    which must be confirmed with control+shift+enter, not just with enter.

    (b) With built-in functions:

    =SUMPRODUCT(--(A2:A15="Include"),--(B2:B15<>""),--((MATCH(A2:A15&"#"&B2:B15,A2:A15&"#"&B2:B15,0)=ROW(INDEX(A2:A15,0,0))-ROW(A2)+1)))

    K wrote:
    > Thanks so much for this string, it was exactly the info I needed...
    >
    > But - I tried this with my data (4000 rows, one column with values "Include"
    > and "Exclude" that is the criteria for counting the unique text values in the
    > second column), and ended up with a formula result 1043.4907. Do I round up
    > or down???
    >
    > =SUMPRODUCT((A2:A3964="Include)/COUNTIF(D2:D3964, D2:D3964&""))
    >
    > I don't understand how the formula works or I would troubleshoot it myself
    >
    > "Bob Phillips" wrote:
    >
    >
    >>=SUMPRODUCT((A1:A20=1)/COUNTIF(B1:B20,B1:B20&""))
    >>
    >>--
    >>
    >>HTH
    >>
    >>RP
    >>(remove nothere from the email address if mailing direct)
    >>
    >>
    >>"carl" <carl@discussions.microsoft.com> wrote in message
    >>news:7CEF6B1D-B90D-49E1-91F5-448278DF6DE4@microsoft.com...
    >>
    >>>I have my data like so:
    >>>
    >>>ColA ColB
    >>>1 A
    >>>1 B
    >>>2 A
    >>>2 B
    >>>1 C
    >>>1 D
    >>>
    >>>Is there a way yo count the number of unique values in ColB if ColA value
    >>>equals 1.
    >>>
    >>>So in the above, the answer would be 4.
    >>>
    >>>Thank you in advance.
    >>>

    >>
    >>
    >>


    --

    [1] The SumProduct function should implicitly coerce the truth values to
    their Excel numeric equivalents.
    [2] The lookup functions should have an optional argument for the return
    value, defaulting to #N/A in its absence.

  12. #12
    K
    Guest

    Re: Counting Unique Values

    Thanks so much for this string, it was exactly the info I needed...

    But - I tried this with my data (4000 rows, one column with values "Include"
    and "Exclude" that is the criteria for counting the unique text values in the
    second column), and ended up with a formula result 1043.4907. Do I round up
    or down???

    =SUMPRODUCT((A2:A3964="Include)/COUNTIF(D2:D3964, D2:D3964&""))

    I don't understand how the formula works or I would troubleshoot it myself

    "Bob Phillips" wrote:

    > =SUMPRODUCT((A1:A20=1)/COUNTIF(B1:B20,B1:B20&""))
    >
    > --
    >
    > HTH
    >
    > RP
    > (remove nothere from the email address if mailing direct)
    >
    >
    > "carl" <carl@discussions.microsoft.com> wrote in message
    > news:7CEF6B1D-B90D-49E1-91F5-448278DF6DE4@microsoft.com...
    > > I have my data like so:
    > >
    > > ColA ColB
    > > 1 A
    > > 1 B
    > > 2 A
    > > 2 B
    > > 1 C
    > > 1 D
    > >
    > > Is there a way yo count the number of unique values in ColB if ColA value
    > > equals 1.
    > >
    > > So in the above, the answer would be 4.
    > >
    > > Thank you in advance.
    > >

    >
    >
    >


  13. #13
    Bob Phillips
    Guest

    Re: Counting Unique Values


    "Aladin Akyurek" <akyurek@xs4all.nl> wrote in message
    news:42af48c4$0$95844$e4fe514c@news.xs4all.nl...
    > Bob Phillips wrote:
    > > =SUMPRODUCT((A1:A20=1)/COUNTIF(B1:B20,B1:B20&""))
    > >

    >
    > Did you test that? Here is a sample:


    Of course I did, and it worked with data as presented. I didn't test with
    gaps in column B, but that is simply corrected if necessary.



  14. #14
    Aladin Akyurek
    Guest

    Re: Counting Unique Values

    Bob Phillips wrote:
    > =SUMPRODUCT((A1:A20=1)/COUNTIF(B1:B20,B1:B20&""))
    >


    Did you test that? Here is a sample:

    {1,"A";0,"B";2,"A";2,"B";1,0;1,"D"}

    where 0 stands for empty cells. Formula blanks [ ="" ] would have the
    same effect.

    --

    [1] The SumProduct function should implicitly coerce the truth values to
    their Excel numeric equivalents.
    [2] The lookup functions should have an optional argument for the return
    value, defaulting to #N/A in its absence.

  15. #15
    Aladin Akyurek
    Guest

    Re: Counting Unique Values

    carl wrote:
    > I have my data like so:
    >
    > ColA ColB
    > 1 A
    > 1 B
    > 2 A
    > 2 B
    > 1 C
    > 1 D
    >
    > Is there a way yo count the number of unique values in ColB if ColA value
    > equals 1.
    >
    > So in the above, the answer would be 4.
    >
    > Thank you in advance.
    >


    If you have Longre's morefunc.xll add-in:

    =COUNTDIFF(IF($A$2:$A$7=1,$B$2:$B$7,0),FALSE,0)

    which you need to confirm with control+shift+enter.

    Or:

    =COUNT(1/FREQUENCY(IF((A2:A7=1)*(B2:B7<>""),MATCH(B2:B7,B2:B7,0)),ROW(INDEX(B2:B7,0,0))-ROW(B2)+1))

    which must be confirmed with control+shift+enter.
    --

    [1] The SumProduct function should implicitly coerce the truth values to
    their Excel numeric equivalents.
    [2] The lookup functions should have an optional argument for the return
    value, defaulting to #N/A in its absence.

  16. #16
    Domenic
    Guest

    Re: Counting Unique Values

    Try...

    =SUM(IF(FREQUENCY(IF((A1:A6=1)*(B1:B6<>""),MATCH(B1:B6,B1:B6,0)),ROW(INDE
    X(B1:B6,0,0))-ROW(B1)+1)>0,1,0))

    OR

    =COUNT(1/FREQUENCY(IF((A1:A6=1)*(B1:B6<>""),MATCH(B1:B6,B1:B6,0)),ROW(IND
    EX(B1:B6,0,0))-ROW(B1)+1))

    Both these formulas need to be confirmed with CONTROL+SHIFT+ENTER, not
    just ENTER.

    Hope this helps!

    In article <7CEF6B1D-B90D-49E1-91F5-448278DF6DE4@microsoft.com>,
    "carl" <carl@discussions.microsoft.com> wrote:

    > I have my data like so:
    >
    > ColA ColB
    > 1 A
    > 1 B
    > 2 A
    > 2 B
    > 1 C
    > 1 D
    >
    > Is there a way yo count the number of unique values in ColB if ColA value
    > equals 1.
    >
    > So in the above, the answer would be 4.
    >
    > Thank you in advance.


  17. #17
    RagDyer
    Guest

    Re: Counting Unique Values

    And ... if Column B should happen to contain blanks, you could try this:

    =SUMPRODUCT((A1:A20=1)/COUNTIF(B1:B20,B1:B20&"")*(B1:B20<>""))
    --
    HTH,

    RD
    ==============================================
    Please keep all correspondence within the Group, so all may benefit!
    ==============================================



    "Bob Phillips" <bob.phillips@notheretiscali.co.uk> wrote in message
    news:OC7LU$RcFHA.1392@TK2MSFTNGP14.phx.gbl...
    > =SUMPRODUCT((A1:A20=1)/COUNTIF(B1:B20,B1:B20&""))
    >
    > --
    >
    > HTH
    >
    > RP
    > (remove nothere from the email address if mailing direct)
    >
    >
    > "carl" <carl@discussions.microsoft.com> wrote in message
    > news:7CEF6B1D-B90D-49E1-91F5-448278DF6DE4@microsoft.com...
    > > I have my data like so:
    > >
    > > ColA ColB
    > > 1 A
    > > 1 B
    > > 2 A
    > > 2 B
    > > 1 C
    > > 1 D
    > >
    > > Is there a way yo count the number of unique values in ColB if ColA

    value
    > > equals 1.
    > >
    > > So in the above, the answer would be 4.
    > >
    > > Thank you in advance.
    > >

    >
    >



  18. #18
    Bob Phillips
    Guest

    Re: Counting Unique Values

    =SUMPRODUCT((A1:A20=1)/COUNTIF(B1:B20,B1:B20&""))

    --

    HTH

    RP
    (remove nothere from the email address if mailing direct)


    "carl" <carl@discussions.microsoft.com> wrote in message
    news:7CEF6B1D-B90D-49E1-91F5-448278DF6DE4@microsoft.com...
    > I have my data like so:
    >
    > ColA ColB
    > 1 A
    > 1 B
    > 2 A
    > 2 B
    > 1 C
    > 1 D
    >
    > Is there a way yo count the number of unique values in ColB if ColA value
    > equals 1.
    >
    > So in the above, the answer would be 4.
    >
    > Thank you in advance.
    >




  19. #19
    Domenic
    Guest

    Re: Counting Unique Values

    Try...

    =SUM(IF(FREQUENCY(IF((A1:A6=1)*(B1:B6<>""),MATCH(B1:B6,B1:B6,0)),ROW(INDE
    X(B1:B6,0,0))-ROW(B1)+1)>0,1,0))

    OR

    =COUNT(1/FREQUENCY(IF((A1:A6=1)*(B1:B6<>""),MATCH(B1:B6,B1:B6,0)),ROW(IND
    EX(B1:B6,0,0))-ROW(B1)+1))

    Both these formulas need to be confirmed with CONTROL+SHIFT+ENTER, not
    just ENTER.

    Hope this helps!

    In article <7CEF6B1D-B90D-49E1-91F5-448278DF6DE4@microsoft.com>,
    "carl" <carl@discussions.microsoft.com> wrote:

    > I have my data like so:
    >
    > ColA ColB
    > 1 A
    > 1 B
    > 2 A
    > 2 B
    > 1 C
    > 1 D
    >
    > Is there a way yo count the number of unique values in ColB if ColA value
    > equals 1.
    >
    > So in the above, the answer would be 4.
    >
    > Thank you in advance.


  20. #20
    Aladin Akyurek
    Guest

    Re: Counting Unique Values

    carl wrote:
    > I have my data like so:
    >
    > ColA ColB
    > 1 A
    > 1 B
    > 2 A
    > 2 B
    > 1 C
    > 1 D
    >
    > Is there a way yo count the number of unique values in ColB if ColA value
    > equals 1.
    >
    > So in the above, the answer would be 4.
    >
    > Thank you in advance.
    >


    If you have Longre's morefunc.xll add-in:

    =COUNTDIFF(IF($A$2:$A$7=1,$B$2:$B$7,0),FALSE,0)

    which you need to confirm with control+shift+enter.

    Or:

    =COUNT(1/FREQUENCY(IF((A2:A7=1)*(B2:B7<>""),MATCH(B2:B7,B2:B7,0)),ROW(INDEX(B2:B7,0,0))-ROW(B2)+1))

    which must be confirmed with control+shift+enter.
    --

    [1] The SumProduct function should implicitly coerce the truth values to
    their Excel numeric equivalents.
    [2] The lookup functions should have an optional argument for the return
    value, defaulting to #N/A in its absence.

  21. #21
    Bob Phillips
    Guest

    Re: Counting Unique Values

    =SUMPRODUCT((A1:A20=1)/COUNTIF(B1:B20,B1:B20&""))

    --

    HTH

    RP
    (remove nothere from the email address if mailing direct)


    "carl" <carl@discussions.microsoft.com> wrote in message
    news:7CEF6B1D-B90D-49E1-91F5-448278DF6DE4@microsoft.com...
    > I have my data like so:
    >
    > ColA ColB
    > 1 A
    > 1 B
    > 2 A
    > 2 B
    > 1 C
    > 1 D
    >
    > Is there a way yo count the number of unique values in ColB if ColA value
    > equals 1.
    >
    > So in the above, the answer would be 4.
    >
    > Thank you in advance.
    >




  22. #22
    Aladin Akyurek
    Guest

    Re: Counting Unique Values

    The option (b) can be shorter:

    =SUMPRODUCT(--(A2:A15="Include"),--(B2:B15<>""),--((MATCH(A2:A15&"#"&B2:B15,A2:A15&"#"&B2:B15,0)=ROW(A2:A15)-ROW(A2)+1)))

    I wonder if

    =SUMPRODUCT(--(A2:A15="Include"),--(B2:B15<>""),--ISNUMBER(MATCH(MATCH(A2:A15&"#"&B2:B15,A2:A15&"#"&B2:B15,0),ROW(A2:A15)-ROW(A2)+1,0)))

    would calculate faster.

    Aladin Akyurek wrote:
    > Two options...
    >
    > {a) If you have the latest version of Longre's morefunc.xll add-in:
    >
    > =COUNTDIFF(IF(A2:A15="Include",IF(B2:B15<>"",B2:B15)),FALSE,FALSE)
    >
    > which must be confirmed with control+shift+enter, not just with enter.
    >
    > (b) With built-in functions:
    >
    > =SUMPRODUCT(--(A2:A15="Include"),--(B2:B15<>""),--((MATCH(A2:A15&"#"&B2:B15,A2:A15&"#"&B2:B15,0)=ROW(INDEX(A2:A15,0,0))-ROW(A2)+1)))
    >
    >
    > K wrote:
    >
    >> Thanks so much for this string, it was exactly the info I needed...
    >> But - I tried this with my data (4000 rows, one column with values
    >> "Include" and "Exclude" that is the criteria for counting the unique
    >> text values in the second column), and ended up with a formula result
    >> 1043.4907. Do I round up or down???
    >>
    >> =SUMPRODUCT((A2:A3964="Include)/COUNTIF(D2:D3964, D2:D3964&""))
    >>
    >> I don't understand how the formula works or I would troubleshoot it
    >> myself
    >> "Bob Phillips" wrote:
    >>
    >>
    >>> =SUMPRODUCT((A1:A20=1)/COUNTIF(B1:B20,B1:B20&""))
    >>>
    >>> --
    >>>
    >>> HTH
    >>>
    >>> RP
    >>> (remove nothere from the email address if mailing direct)
    >>>
    >>>
    >>> "carl" <carl@discussions.microsoft.com> wrote in message
    >>> news:7CEF6B1D-B90D-49E1-91F5-448278DF6DE4@microsoft.com...
    >>>
    >>>> I have my data like so:
    >>>>
    >>>> ColA ColB
    >>>> 1 A
    >>>> 1 B
    >>>> 2 A
    >>>> 2 B
    >>>> 1 C
    >>>> 1 D
    >>>>
    >>>> Is there a way yo count the number of unique values in ColB if ColA
    >>>> value
    >>>> equals 1.
    >>>>
    >>>> So in the above, the answer would be 4.
    >>>>
    >>>> Thank you in advance.
    >>>>
    >>>
    >>>
    >>>

    >


    --

    [1] The SumProduct function should implicitly coerce the truth values to
    their Excel numeric equivalents.
    [2] The lookup functions should have an optional argument for the return
    value, defaulting to #N/A in its absence.

  23. #23
    Aladin Akyurek
    Guest

    Re: Counting Unique Values

    Bob Phillips wrote:
    > =SUMPRODUCT((A1:A20=1)/COUNTIF(B1:B20,B1:B20&""))
    >


    Did you test that? Here is a sample:

    {1,"A";0,"B";2,"A";2,"B";1,0;1,"D"}

    where 0 stands for empty cells. Formula blanks [ ="" ] would have the
    same effect.

    --

    [1] The SumProduct function should implicitly coerce the truth values to
    their Excel numeric equivalents.
    [2] The lookup functions should have an optional argument for the return
    value, defaulting to #N/A in its absence.

  24. #24
    Bob Phillips
    Guest

    Re: Counting Unique Values


    "Aladin Akyurek" <akyurek@xs4all.nl> wrote in message
    news:42af48c4$0$95844$e4fe514c@news.xs4all.nl...
    > Bob Phillips wrote:
    > > =SUMPRODUCT((A1:A20=1)/COUNTIF(B1:B20,B1:B20&""))
    > >

    >
    > Did you test that? Here is a sample:


    Of course I did, and it worked with data as presented. I didn't test with
    gaps in column B, but that is simply corrected if necessary.



  25. #25
    Aladin Akyurek
    Guest

    Re: Counting Unique Values

    Two options...

    {a) If you have the latest version of Longre's morefunc.xll add-in:

    =COUNTDIFF(IF(A2:A15="Include",IF(B2:B15<>"",B2:B15)),FALSE,FALSE)

    which must be confirmed with control+shift+enter, not just with enter.

    (b) With built-in functions:

    =SUMPRODUCT(--(A2:A15="Include"),--(B2:B15<>""),--((MATCH(A2:A15&"#"&B2:B15,A2:A15&"#"&B2:B15,0)=ROW(INDEX(A2:A15,0,0))-ROW(A2)+1)))

    K wrote:
    > Thanks so much for this string, it was exactly the info I needed...
    >
    > But - I tried this with my data (4000 rows, one column with values "Include"
    > and "Exclude" that is the criteria for counting the unique text values in the
    > second column), and ended up with a formula result 1043.4907. Do I round up
    > or down???
    >
    > =SUMPRODUCT((A2:A3964="Include)/COUNTIF(D2:D3964, D2:D3964&""))
    >
    > I don't understand how the formula works or I would troubleshoot it myself
    >
    > "Bob Phillips" wrote:
    >
    >
    >>=SUMPRODUCT((A1:A20=1)/COUNTIF(B1:B20,B1:B20&""))
    >>
    >>--
    >>
    >>HTH
    >>
    >>RP
    >>(remove nothere from the email address if mailing direct)
    >>
    >>
    >>"carl" <carl@discussions.microsoft.com> wrote in message
    >>news:7CEF6B1D-B90D-49E1-91F5-448278DF6DE4@microsoft.com...
    >>
    >>>I have my data like so:
    >>>
    >>>ColA ColB
    >>>1 A
    >>>1 B
    >>>2 A
    >>>2 B
    >>>1 C
    >>>1 D
    >>>
    >>>Is there a way yo count the number of unique values in ColB if ColA value
    >>>equals 1.
    >>>
    >>>So in the above, the answer would be 4.
    >>>
    >>>Thank you in advance.
    >>>

    >>
    >>
    >>


    --

    [1] The SumProduct function should implicitly coerce the truth values to
    their Excel numeric equivalents.
    [2] The lookup functions should have an optional argument for the return
    value, defaulting to #N/A in its absence.

  26. #26
    K
    Guest

    Re: Counting Unique Values

    Thanks so much for this string, it was exactly the info I needed...

    But - I tried this with my data (4000 rows, one column with values "Include"
    and "Exclude" that is the criteria for counting the unique text values in the
    second column), and ended up with a formula result 1043.4907. Do I round up
    or down???

    =SUMPRODUCT((A2:A3964="Include)/COUNTIF(D2:D3964, D2:D3964&""))

    I don't understand how the formula works or I would troubleshoot it myself

    "Bob Phillips" wrote:

    > =SUMPRODUCT((A1:A20=1)/COUNTIF(B1:B20,B1:B20&""))
    >
    > --
    >
    > HTH
    >
    > RP
    > (remove nothere from the email address if mailing direct)
    >
    >
    > "carl" <carl@discussions.microsoft.com> wrote in message
    > news:7CEF6B1D-B90D-49E1-91F5-448278DF6DE4@microsoft.com...
    > > I have my data like so:
    > >
    > > ColA ColB
    > > 1 A
    > > 1 B
    > > 2 A
    > > 2 B
    > > 1 C
    > > 1 D
    > >
    > > Is there a way yo count the number of unique values in ColB if ColA value
    > > equals 1.
    > >
    > > So in the above, the answer would be 4.
    > >
    > > Thank you in advance.
    > >

    >
    >
    >


  27. #27
    RagDyer
    Guest

    Re: Counting Unique Values

    And ... if Column B should happen to contain blanks, you could try this:

    =SUMPRODUCT((A1:A20=1)/COUNTIF(B1:B20,B1:B20&"")*(B1:B20<>""))
    --
    HTH,

    RD
    ==============================================
    Please keep all correspondence within the Group, so all may benefit!
    ==============================================



    "Bob Phillips" <bob.phillips@notheretiscali.co.uk> wrote in message
    news:OC7LU$RcFHA.1392@TK2MSFTNGP14.phx.gbl...
    > =SUMPRODUCT((A1:A20=1)/COUNTIF(B1:B20,B1:B20&""))
    >
    > --
    >
    > HTH
    >
    > RP
    > (remove nothere from the email address if mailing direct)
    >
    >
    > "carl" <carl@discussions.microsoft.com> wrote in message
    > news:7CEF6B1D-B90D-49E1-91F5-448278DF6DE4@microsoft.com...
    > > I have my data like so:
    > >
    > > ColA ColB
    > > 1 A
    > > 1 B
    > > 2 A
    > > 2 B
    > > 1 C
    > > 1 D
    > >
    > > Is there a way yo count the number of unique values in ColB if ColA

    value
    > > equals 1.
    > >
    > > So in the above, the answer would be 4.
    > >
    > > Thank you in advance.
    > >

    >
    >



  28. #28
    carl
    Guest

    Counting Unique Values

    I have my data like so:

    ColA ColB
    1 A
    1 B
    2 A
    2 B
    1 C
    1 D

    Is there a way yo count the number of unique values in ColB if ColA value
    equals 1.

    So in the above, the answer would be 4.

    Thank you in advance.


  29. #29
    RagDyer
    Guest

    Re: Counting Unique Values

    And ... if Column B should happen to contain blanks, you could try this:

    =SUMPRODUCT((A1:A20=1)/COUNTIF(B1:B20,B1:B20&"")*(B1:B20<>""))
    --
    HTH,

    RD
    ==============================================
    Please keep all correspondence within the Group, so all may benefit!
    ==============================================



    "Bob Phillips" <bob.phillips@notheretiscali.co.uk> wrote in message
    news:OC7LU$RcFHA.1392@TK2MSFTNGP14.phx.gbl...
    > =SUMPRODUCT((A1:A20=1)/COUNTIF(B1:B20,B1:B20&""))
    >
    > --
    >
    > HTH
    >
    > RP
    > (remove nothere from the email address if mailing direct)
    >
    >
    > "carl" <carl@discussions.microsoft.com> wrote in message
    > news:7CEF6B1D-B90D-49E1-91F5-448278DF6DE4@microsoft.com...
    > > I have my data like so:
    > >
    > > ColA ColB
    > > 1 A
    > > 1 B
    > > 2 A
    > > 2 B
    > > 1 C
    > > 1 D
    > >
    > > Is there a way yo count the number of unique values in ColB if ColA

    value
    > > equals 1.
    > >
    > > So in the above, the answer would be 4.
    > >
    > > Thank you in advance.
    > >

    >
    >



  30. #30
    Bob Phillips
    Guest

    Re: Counting Unique Values

    =SUMPRODUCT((A1:A20=1)/COUNTIF(B1:B20,B1:B20&""))

    --

    HTH

    RP
    (remove nothere from the email address if mailing direct)


    "carl" <carl@discussions.microsoft.com> wrote in message
    news:7CEF6B1D-B90D-49E1-91F5-448278DF6DE4@microsoft.com...
    > I have my data like so:
    >
    > ColA ColB
    > 1 A
    > 1 B
    > 2 A
    > 2 B
    > 1 C
    > 1 D
    >
    > Is there a way yo count the number of unique values in ColB if ColA value
    > equals 1.
    >
    > So in the above, the answer would be 4.
    >
    > Thank you in advance.
    >




  31. #31
    Domenic
    Guest

    Re: Counting Unique Values

    Try...

    =SUM(IF(FREQUENCY(IF((A1:A6=1)*(B1:B6<>""),MATCH(B1:B6,B1:B6,0)),ROW(INDE
    X(B1:B6,0,0))-ROW(B1)+1)>0,1,0))

    OR

    =COUNT(1/FREQUENCY(IF((A1:A6=1)*(B1:B6<>""),MATCH(B1:B6,B1:B6,0)),ROW(IND
    EX(B1:B6,0,0))-ROW(B1)+1))

    Both these formulas need to be confirmed with CONTROL+SHIFT+ENTER, not
    just ENTER.

    Hope this helps!

    In article <7CEF6B1D-B90D-49E1-91F5-448278DF6DE4@microsoft.com>,
    "carl" <carl@discussions.microsoft.com> wrote:

    > I have my data like so:
    >
    > ColA ColB
    > 1 A
    > 1 B
    > 2 A
    > 2 B
    > 1 C
    > 1 D
    >
    > Is there a way yo count the number of unique values in ColB if ColA value
    > equals 1.
    >
    > So in the above, the answer would be 4.
    >
    > Thank you in advance.


  32. #32
    Aladin Akyurek
    Guest

    Re: Counting Unique Values

    carl wrote:
    > I have my data like so:
    >
    > ColA ColB
    > 1 A
    > 1 B
    > 2 A
    > 2 B
    > 1 C
    > 1 D
    >
    > Is there a way yo count the number of unique values in ColB if ColA value
    > equals 1.
    >
    > So in the above, the answer would be 4.
    >
    > Thank you in advance.
    >


    If you have Longre's morefunc.xll add-in:

    =COUNTDIFF(IF($A$2:$A$7=1,$B$2:$B$7,0),FALSE,0)

    which you need to confirm with control+shift+enter.

    Or:

    =COUNT(1/FREQUENCY(IF((A2:A7=1)*(B2:B7<>""),MATCH(B2:B7,B2:B7,0)),ROW(INDEX(B2:B7,0,0))-ROW(B2)+1))

    which must be confirmed with control+shift+enter.
    --

    [1] The SumProduct function should implicitly coerce the truth values to
    their Excel numeric equivalents.
    [2] The lookup functions should have an optional argument for the return
    value, defaulting to #N/A in its absence.

  33. #33
    Aladin Akyurek
    Guest

    Re: Counting Unique Values

    Bob Phillips wrote:
    > =SUMPRODUCT((A1:A20=1)/COUNTIF(B1:B20,B1:B20&""))
    >


    Did you test that? Here is a sample:

    {1,"A";0,"B";2,"A";2,"B";1,0;1,"D"}

    where 0 stands for empty cells. Formula blanks [ ="" ] would have the
    same effect.

    --

    [1] The SumProduct function should implicitly coerce the truth values to
    their Excel numeric equivalents.
    [2] The lookup functions should have an optional argument for the return
    value, defaulting to #N/A in its absence.

  34. #34
    Bob Phillips
    Guest

    Re: Counting Unique Values


    "Aladin Akyurek" <akyurek@xs4all.nl> wrote in message
    news:42af48c4$0$95844$e4fe514c@news.xs4all.nl...
    > Bob Phillips wrote:
    > > =SUMPRODUCT((A1:A20=1)/COUNTIF(B1:B20,B1:B20&""))
    > >

    >
    > Did you test that? Here is a sample:


    Of course I did, and it worked with data as presented. I didn't test with
    gaps in column B, but that is simply corrected if necessary.



  35. #35
    K
    Guest

    Re: Counting Unique Values

    Thanks so much for this string, it was exactly the info I needed...

    But - I tried this with my data (4000 rows, one column with values "Include"
    and "Exclude" that is the criteria for counting the unique text values in the
    second column), and ended up with a formula result 1043.4907. Do I round up
    or down???

    =SUMPRODUCT((A2:A3964="Include)/COUNTIF(D2:D3964, D2:D3964&""))

    I don't understand how the formula works or I would troubleshoot it myself

    "Bob Phillips" wrote:

    > =SUMPRODUCT((A1:A20=1)/COUNTIF(B1:B20,B1:B20&""))
    >
    > --
    >
    > HTH
    >
    > RP
    > (remove nothere from the email address if mailing direct)
    >
    >
    > "carl" <carl@discussions.microsoft.com> wrote in message
    > news:7CEF6B1D-B90D-49E1-91F5-448278DF6DE4@microsoft.com...
    > > I have my data like so:
    > >
    > > ColA ColB
    > > 1 A
    > > 1 B
    > > 2 A
    > > 2 B
    > > 1 C
    > > 1 D
    > >
    > > Is there a way yo count the number of unique values in ColB if ColA value
    > > equals 1.
    > >
    > > So in the above, the answer would be 4.
    > >
    > > Thank you in advance.
    > >

    >
    >
    >


  36. #36
    Aladin Akyurek
    Guest

    Re: Counting Unique Values

    Two options...

    {a) If you have the latest version of Longre's morefunc.xll add-in:

    =COUNTDIFF(IF(A2:A15="Include",IF(B2:B15<>"",B2:B15)),FALSE,FALSE)

    which must be confirmed with control+shift+enter, not just with enter.

    (b) With built-in functions:

    =SUMPRODUCT(--(A2:A15="Include"),--(B2:B15<>""),--((MATCH(A2:A15&"#"&B2:B15,A2:A15&"#"&B2:B15,0)=ROW(INDEX(A2:A15,0,0))-ROW(A2)+1)))

    K wrote:
    > Thanks so much for this string, it was exactly the info I needed...
    >
    > But - I tried this with my data (4000 rows, one column with values "Include"
    > and "Exclude" that is the criteria for counting the unique text values in the
    > second column), and ended up with a formula result 1043.4907. Do I round up
    > or down???
    >
    > =SUMPRODUCT((A2:A3964="Include)/COUNTIF(D2:D3964, D2:D3964&""))
    >
    > I don't understand how the formula works or I would troubleshoot it myself
    >
    > "Bob Phillips" wrote:
    >
    >
    >>=SUMPRODUCT((A1:A20=1)/COUNTIF(B1:B20,B1:B20&""))
    >>
    >>--
    >>
    >>HTH
    >>
    >>RP
    >>(remove nothere from the email address if mailing direct)
    >>
    >>
    >>"carl" <carl@discussions.microsoft.com> wrote in message
    >>news:7CEF6B1D-B90D-49E1-91F5-448278DF6DE4@microsoft.com...
    >>
    >>>I have my data like so:
    >>>
    >>>ColA ColB
    >>>1 A
    >>>1 B
    >>>2 A
    >>>2 B
    >>>1 C
    >>>1 D
    >>>
    >>>Is there a way yo count the number of unique values in ColB if ColA value
    >>>equals 1.
    >>>
    >>>So in the above, the answer would be 4.
    >>>
    >>>Thank you in advance.
    >>>

    >>
    >>
    >>


    --

    [1] The SumProduct function should implicitly coerce the truth values to
    their Excel numeric equivalents.
    [2] The lookup functions should have an optional argument for the return
    value, defaulting to #N/A in its absence.

  37. #37
    Aladin Akyurek
    Guest

    Re: Counting Unique Values

    The option (b) can be shorter:

    =SUMPRODUCT(--(A2:A15="Include"),--(B2:B15<>""),--((MATCH(A2:A15&"#"&B2:B15,A2:A15&"#"&B2:B15,0)=ROW(A2:A15)-ROW(A2)+1)))

    I wonder if

    =SUMPRODUCT(--(A2:A15="Include"),--(B2:B15<>""),--ISNUMBER(MATCH(MATCH(A2:A15&"#"&B2:B15,A2:A15&"#"&B2:B15,0),ROW(A2:A15)-ROW(A2)+1,0)))

    would calculate faster.

    Aladin Akyurek wrote:
    > Two options...
    >
    > {a) If you have the latest version of Longre's morefunc.xll add-in:
    >
    > =COUNTDIFF(IF(A2:A15="Include",IF(B2:B15<>"",B2:B15)),FALSE,FALSE)
    >
    > which must be confirmed with control+shift+enter, not just with enter.
    >
    > (b) With built-in functions:
    >
    > =SUMPRODUCT(--(A2:A15="Include"),--(B2:B15<>""),--((MATCH(A2:A15&"#"&B2:B15,A2:A15&"#"&B2:B15,0)=ROW(INDEX(A2:A15,0,0))-ROW(A2)+1)))
    >
    >
    > K wrote:
    >
    >> Thanks so much for this string, it was exactly the info I needed...
    >> But - I tried this with my data (4000 rows, one column with values
    >> "Include" and "Exclude" that is the criteria for counting the unique
    >> text values in the second column), and ended up with a formula result
    >> 1043.4907. Do I round up or down???
    >>
    >> =SUMPRODUCT((A2:A3964="Include)/COUNTIF(D2:D3964, D2:D3964&""))
    >>
    >> I don't understand how the formula works or I would troubleshoot it
    >> myself
    >> "Bob Phillips" wrote:
    >>
    >>
    >>> =SUMPRODUCT((A1:A20=1)/COUNTIF(B1:B20,B1:B20&""))
    >>>
    >>> --
    >>>
    >>> HTH
    >>>
    >>> RP
    >>> (remove nothere from the email address if mailing direct)
    >>>
    >>>
    >>> "carl" <carl@discussions.microsoft.com> wrote in message
    >>> news:7CEF6B1D-B90D-49E1-91F5-448278DF6DE4@microsoft.com...
    >>>
    >>>> I have my data like so:
    >>>>
    >>>> ColA ColB
    >>>> 1 A
    >>>> 1 B
    >>>> 2 A
    >>>> 2 B
    >>>> 1 C
    >>>> 1 D
    >>>>
    >>>> Is there a way yo count the number of unique values in ColB if ColA
    >>>> value
    >>>> equals 1.
    >>>>
    >>>> So in the above, the answer would be 4.
    >>>>
    >>>> Thank you in advance.
    >>>>
    >>>
    >>>
    >>>

    >


    --

    [1] The SumProduct function should implicitly coerce the truth values to
    their Excel numeric equivalents.
    [2] The lookup functions should have an optional argument for the return
    value, defaulting to #N/A in its absence.

  38. #38
    Aladin Akyurek
    Guest

    Re: Counting Unique Values

    The option (b) can be shorter:

    =SUMPRODUCT(--(A2:A15="Include"),--(B2:B15<>""),--((MATCH(A2:A15&"#"&B2:B15,A2:A15&"#"&B2:B15,0)=ROW(A2:A15)-ROW(A2)+1)))

    I wonder if

    =SUMPRODUCT(--(A2:A15="Include"),--(B2:B15<>""),--ISNUMBER(MATCH(MATCH(A2:A15&"#"&B2:B15,A2:A15&"#"&B2:B15,0),ROW(A2:A15)-ROW(A2)+1,0)))

    would calculate faster.

    Aladin Akyurek wrote:
    > Two options...
    >
    > {a) If you have the latest version of Longre's morefunc.xll add-in:
    >
    > =COUNTDIFF(IF(A2:A15="Include",IF(B2:B15<>"",B2:B15)),FALSE,FALSE)
    >
    > which must be confirmed with control+shift+enter, not just with enter.
    >
    > (b) With built-in functions:
    >
    > =SUMPRODUCT(--(A2:A15="Include"),--(B2:B15<>""),--((MATCH(A2:A15&"#"&B2:B15,A2:A15&"#"&B2:B15,0)=ROW(INDEX(A2:A15,0,0))-ROW(A2)+1)))
    >
    >
    > K wrote:
    >
    >> Thanks so much for this string, it was exactly the info I needed...
    >> But - I tried this with my data (4000 rows, one column with values
    >> "Include" and "Exclude" that is the criteria for counting the unique
    >> text values in the second column), and ended up with a formula result
    >> 1043.4907. Do I round up or down???
    >>
    >> =SUMPRODUCT((A2:A3964="Include)/COUNTIF(D2:D3964, D2:D3964&""))
    >>
    >> I don't understand how the formula works or I would troubleshoot it
    >> myself
    >> "Bob Phillips" wrote:
    >>
    >>
    >>> =SUMPRODUCT((A1:A20=1)/COUNTIF(B1:B20,B1:B20&""))
    >>>
    >>> --
    >>>
    >>> HTH
    >>>
    >>> RP
    >>> (remove nothere from the email address if mailing direct)
    >>>
    >>>
    >>> "carl" <carl@discussions.microsoft.com> wrote in message
    >>> news:7CEF6B1D-B90D-49E1-91F5-448278DF6DE4@microsoft.com...
    >>>
    >>>> I have my data like so:
    >>>>
    >>>> ColA ColB
    >>>> 1 A
    >>>> 1 B
    >>>> 2 A
    >>>> 2 B
    >>>> 1 C
    >>>> 1 D
    >>>>
    >>>> Is there a way yo count the number of unique values in ColB if ColA
    >>>> value
    >>>> equals 1.
    >>>>
    >>>> So in the above, the answer would be 4.
    >>>>
    >>>> Thank you in advance.
    >>>>
    >>>
    >>>
    >>>

    >


    --

    [1] The SumProduct function should implicitly coerce the truth values to
    their Excel numeric equivalents.
    [2] The lookup functions should have an optional argument for the return
    value, defaulting to #N/A in its absence.

  39. #39
    K
    Guest

    Re: Counting Unique Values

    Thanks so much for this string, it was exactly the info I needed...

    But - I tried this with my data (4000 rows, one column with values "Include"
    and "Exclude" that is the criteria for counting the unique text values in the
    second column), and ended up with a formula result 1043.4907. Do I round up
    or down???

    =SUMPRODUCT((A2:A3964="Include)/COUNTIF(D2:D3964, D2:D3964&""))

    I don't understand how the formula works or I would troubleshoot it myself

    "Bob Phillips" wrote:

    > =SUMPRODUCT((A1:A20=1)/COUNTIF(B1:B20,B1:B20&""))
    >
    > --
    >
    > HTH
    >
    > RP
    > (remove nothere from the email address if mailing direct)
    >
    >
    > "carl" <carl@discussions.microsoft.com> wrote in message
    > news:7CEF6B1D-B90D-49E1-91F5-448278DF6DE4@microsoft.com...
    > > I have my data like so:
    > >
    > > ColA ColB
    > > 1 A
    > > 1 B
    > > 2 A
    > > 2 B
    > > 1 C
    > > 1 D
    > >
    > > Is there a way yo count the number of unique values in ColB if ColA value
    > > equals 1.
    > >
    > > So in the above, the answer would be 4.
    > >
    > > Thank you in advance.
    > >

    >
    >
    >


  40. #40
    Aladin Akyurek
    Guest

    Re: Counting Unique Values

    Two options...

    {a) If you have the latest version of Longre's morefunc.xll add-in:

    =COUNTDIFF(IF(A2:A15="Include",IF(B2:B15<>"",B2:B15)),FALSE,FALSE)

    which must be confirmed with control+shift+enter, not just with enter.

    (b) With built-in functions:

    =SUMPRODUCT(--(A2:A15="Include"),--(B2:B15<>""),--((MATCH(A2:A15&"#"&B2:B15,A2:A15&"#"&B2:B15,0)=ROW(INDEX(A2:A15,0,0))-ROW(A2)+1)))

    K wrote:
    > Thanks so much for this string, it was exactly the info I needed...
    >
    > But - I tried this with my data (4000 rows, one column with values "Include"
    > and "Exclude" that is the criteria for counting the unique text values in the
    > second column), and ended up with a formula result 1043.4907. Do I round up
    > or down???
    >
    > =SUMPRODUCT((A2:A3964="Include)/COUNTIF(D2:D3964, D2:D3964&""))
    >
    > I don't understand how the formula works or I would troubleshoot it myself
    >
    > "Bob Phillips" wrote:
    >
    >
    >>=SUMPRODUCT((A1:A20=1)/COUNTIF(B1:B20,B1:B20&""))
    >>
    >>--
    >>
    >>HTH
    >>
    >>RP
    >>(remove nothere from the email address if mailing direct)
    >>
    >>
    >>"carl" <carl@discussions.microsoft.com> wrote in message
    >>news:7CEF6B1D-B90D-49E1-91F5-448278DF6DE4@microsoft.com...
    >>
    >>>I have my data like so:
    >>>
    >>>ColA ColB
    >>>1 A
    >>>1 B
    >>>2 A
    >>>2 B
    >>>1 C
    >>>1 D
    >>>
    >>>Is there a way yo count the number of unique values in ColB if ColA value
    >>>equals 1.
    >>>
    >>>So in the above, the answer would be 4.
    >>>
    >>>Thank you in advance.
    >>>

    >>
    >>
    >>


    --

    [1] The SumProduct function should implicitly coerce the truth values to
    their Excel numeric equivalents.
    [2] The lookup functions should have an optional argument for the return
    value, defaulting to #N/A in its absence.

  41. #41
    Aladin Akyurek
    Guest

    Re: Counting Unique Values

    Two options...

    {a) If you have the latest version of Longre's morefunc.xll add-in:

    =COUNTDIFF(IF(A2:A15="Include",IF(B2:B15<>"",B2:B15)),FALSE,FALSE)

    which must be confirmed with control+shift+enter, not just with enter.

    (b) With built-in functions:

    =SUMPRODUCT(--(A2:A15="Include"),--(B2:B15<>""),--((MATCH(A2:A15&"#"&B2:B15,A2:A15&"#"&B2:B15,0)=ROW(INDEX(A2:A15,0,0))-ROW(A2)+1)))

    K wrote:
    > Thanks so much for this string, it was exactly the info I needed...
    >
    > But - I tried this with my data (4000 rows, one column with values "Include"
    > and "Exclude" that is the criteria for counting the unique text values in the
    > second column), and ended up with a formula result 1043.4907. Do I round up
    > or down???
    >
    > =SUMPRODUCT((A2:A3964="Include)/COUNTIF(D2:D3964, D2:D3964&""))
    >
    > I don't understand how the formula works or I would troubleshoot it myself
    >
    > "Bob Phillips" wrote:
    >
    >
    >>=SUMPRODUCT((A1:A20=1)/COUNTIF(B1:B20,B1:B20&""))
    >>
    >>--
    >>
    >>HTH
    >>
    >>RP
    >>(remove nothere from the email address if mailing direct)
    >>
    >>
    >>"carl" <carl@discussions.microsoft.com> wrote in message
    >>news:7CEF6B1D-B90D-49E1-91F5-448278DF6DE4@microsoft.com...
    >>
    >>>I have my data like so:
    >>>
    >>>ColA ColB
    >>>1 A
    >>>1 B
    >>>2 A
    >>>2 B
    >>>1 C
    >>>1 D
    >>>
    >>>Is there a way yo count the number of unique values in ColB if ColA value
    >>>equals 1.
    >>>
    >>>So in the above, the answer would be 4.
    >>>
    >>>Thank you in advance.
    >>>

    >>
    >>
    >>


    --

    [1] The SumProduct function should implicitly coerce the truth values to
    their Excel numeric equivalents.
    [2] The lookup functions should have an optional argument for the return
    value, defaulting to #N/A in its absence.

  42. #42
    Aladin Akyurek
    Guest

    Re: Counting Unique Values

    The option (b) can be shorter:

    =SUMPRODUCT(--(A2:A15="Include"),--(B2:B15<>""),--((MATCH(A2:A15&"#"&B2:B15,A2:A15&"#"&B2:B15,0)=ROW(A2:A15)-ROW(A2)+1)))

    I wonder if

    =SUMPRODUCT(--(A2:A15="Include"),--(B2:B15<>""),--ISNUMBER(MATCH(MATCH(A2:A15&"#"&B2:B15,A2:A15&"#"&B2:B15,0),ROW(A2:A15)-ROW(A2)+1,0)))

    would calculate faster.

    Aladin Akyurek wrote:
    > Two options...
    >
    > {a) If you have the latest version of Longre's morefunc.xll add-in:
    >
    > =COUNTDIFF(IF(A2:A15="Include",IF(B2:B15<>"",B2:B15)),FALSE,FALSE)
    >
    > which must be confirmed with control+shift+enter, not just with enter.
    >
    > (b) With built-in functions:
    >
    > =SUMPRODUCT(--(A2:A15="Include"),--(B2:B15<>""),--((MATCH(A2:A15&"#"&B2:B15,A2:A15&"#"&B2:B15,0)=ROW(INDEX(A2:A15,0,0))-ROW(A2)+1)))
    >
    >
    > K wrote:
    >
    >> Thanks so much for this string, it was exactly the info I needed...
    >> But - I tried this with my data (4000 rows, one column with values
    >> "Include" and "Exclude" that is the criteria for counting the unique
    >> text values in the second column), and ended up with a formula result
    >> 1043.4907. Do I round up or down???
    >>
    >> =SUMPRODUCT((A2:A3964="Include)/COUNTIF(D2:D3964, D2:D3964&""))
    >>
    >> I don't understand how the formula works or I would troubleshoot it
    >> myself
    >> "Bob Phillips" wrote:
    >>
    >>
    >>> =SUMPRODUCT((A1:A20=1)/COUNTIF(B1:B20,B1:B20&""))
    >>>
    >>> --
    >>>
    >>> HTH
    >>>
    >>> RP
    >>> (remove nothere from the email address if mailing direct)
    >>>
    >>>
    >>> "carl" <carl@discussions.microsoft.com> wrote in message
    >>> news:7CEF6B1D-B90D-49E1-91F5-448278DF6DE4@microsoft.com...
    >>>
    >>>> I have my data like so:
    >>>>
    >>>> ColA ColB
    >>>> 1 A
    >>>> 1 B
    >>>> 2 A
    >>>> 2 B
    >>>> 1 C
    >>>> 1 D
    >>>>
    >>>> Is there a way yo count the number of unique values in ColB if ColA
    >>>> value
    >>>> equals 1.
    >>>>
    >>>> So in the above, the answer would be 4.
    >>>>
    >>>> Thank you in advance.
    >>>>
    >>>
    >>>
    >>>

    >


    --

    [1] The SumProduct function should implicitly coerce the truth values to
    their Excel numeric equivalents.
    [2] The lookup functions should have an optional argument for the return
    value, defaulting to #N/A in its absence.

  43. #43
    K
    Guest

    Re: Counting Unique Values

    Thanks so much for this string, it was exactly the info I needed...

    But - I tried this with my data (4000 rows, one column with values "Include"
    and "Exclude" that is the criteria for counting the unique text values in the
    second column), and ended up with a formula result 1043.4907. Do I round up
    or down???

    =SUMPRODUCT((A2:A3964="Include)/COUNTIF(D2:D3964, D2:D3964&""))

    I don't understand how the formula works or I would troubleshoot it myself

    "Bob Phillips" wrote:

    > =SUMPRODUCT((A1:A20=1)/COUNTIF(B1:B20,B1:B20&""))
    >
    > --
    >
    > HTH
    >
    > RP
    > (remove nothere from the email address if mailing direct)
    >
    >
    > "carl" <carl@discussions.microsoft.com> wrote in message
    > news:7CEF6B1D-B90D-49E1-91F5-448278DF6DE4@microsoft.com...
    > > I have my data like so:
    > >
    > > ColA ColB
    > > 1 A
    > > 1 B
    > > 2 A
    > > 2 B
    > > 1 C
    > > 1 D
    > >
    > > Is there a way yo count the number of unique values in ColB if ColA value
    > > equals 1.
    > >
    > > So in the above, the answer would be 4.
    > >
    > > Thank you in advance.
    > >

    >
    >
    >


  44. #44
    Aladin Akyurek
    Guest

    Re: Counting Unique Values

    The option (b) can be shorter:

    =SUMPRODUCT(--(A2:A15="Include"),--(B2:B15<>""),--((MATCH(A2:A15&"#"&B2:B15,A2:A15&"#"&B2:B15,0)=ROW(A2:A15)-ROW(A2)+1)))

    I wonder if

    =SUMPRODUCT(--(A2:A15="Include"),--(B2:B15<>""),--ISNUMBER(MATCH(MATCH(A2:A15&"#"&B2:B15,A2:A15&"#"&B2:B15,0),ROW(A2:A15)-ROW(A2)+1,0)))

    would calculate faster.

    Aladin Akyurek wrote:
    > Two options...
    >
    > {a) If you have the latest version of Longre's morefunc.xll add-in:
    >
    > =COUNTDIFF(IF(A2:A15="Include",IF(B2:B15<>"",B2:B15)),FALSE,FALSE)
    >
    > which must be confirmed with control+shift+enter, not just with enter.
    >
    > (b) With built-in functions:
    >
    > =SUMPRODUCT(--(A2:A15="Include"),--(B2:B15<>""),--((MATCH(A2:A15&"#"&B2:B15,A2:A15&"#"&B2:B15,0)=ROW(INDEX(A2:A15,0,0))-ROW(A2)+1)))
    >
    >
    > K wrote:
    >
    >> Thanks so much for this string, it was exactly the info I needed...
    >> But - I tried this with my data (4000 rows, one column with values
    >> "Include" and "Exclude" that is the criteria for counting the unique
    >> text values in the second column), and ended up with a formula result
    >> 1043.4907. Do I round up or down???
    >>
    >> =SUMPRODUCT((A2:A3964="Include)/COUNTIF(D2:D3964, D2:D3964&""))
    >>
    >> I don't understand how the formula works or I would troubleshoot it
    >> myself
    >> "Bob Phillips" wrote:
    >>
    >>
    >>> =SUMPRODUCT((A1:A20=1)/COUNTIF(B1:B20,B1:B20&""))
    >>>
    >>> --
    >>>
    >>> HTH
    >>>
    >>> RP
    >>> (remove nothere from the email address if mailing direct)
    >>>
    >>>
    >>> "carl" <carl@discussions.microsoft.com> wrote in message
    >>> news:7CEF6B1D-B90D-49E1-91F5-448278DF6DE4@microsoft.com...
    >>>
    >>>> I have my data like so:
    >>>>
    >>>> ColA ColB
    >>>> 1 A
    >>>> 1 B
    >>>> 2 A
    >>>> 2 B
    >>>> 1 C
    >>>> 1 D
    >>>>
    >>>> Is there a way yo count the number of unique values in ColB if ColA
    >>>> value
    >>>> equals 1.
    >>>>
    >>>> So in the above, the answer would be 4.
    >>>>
    >>>> Thank you in advance.
    >>>>
    >>>
    >>>
    >>>

    >


    --

    [1] The SumProduct function should implicitly coerce the truth values to
    their Excel numeric equivalents.
    [2] The lookup functions should have an optional argument for the return
    value, defaulting to #N/A in its absence.

  45. #45
    Aladin Akyurek
    Guest

    Re: Counting Unique Values

    Two options...

    {a) If you have the latest version of Longre's morefunc.xll add-in:

    =COUNTDIFF(IF(A2:A15="Include",IF(B2:B15<>"",B2:B15)),FALSE,FALSE)

    which must be confirmed with control+shift+enter, not just with enter.

    (b) With built-in functions:

    =SUMPRODUCT(--(A2:A15="Include"),--(B2:B15<>""),--((MATCH(A2:A15&"#"&B2:B15,A2:A15&"#"&B2:B15,0)=ROW(INDEX(A2:A15,0,0))-ROW(A2)+1)))

    K wrote:
    > Thanks so much for this string, it was exactly the info I needed...
    >
    > But - I tried this with my data (4000 rows, one column with values "Include"
    > and "Exclude" that is the criteria for counting the unique text values in the
    > second column), and ended up with a formula result 1043.4907. Do I round up
    > or down???
    >
    > =SUMPRODUCT((A2:A3964="Include)/COUNTIF(D2:D3964, D2:D3964&""))
    >
    > I don't understand how the formula works or I would troubleshoot it myself
    >
    > "Bob Phillips" wrote:
    >
    >
    >>=SUMPRODUCT((A1:A20=1)/COUNTIF(B1:B20,B1:B20&""))
    >>
    >>--
    >>
    >>HTH
    >>
    >>RP
    >>(remove nothere from the email address if mailing direct)
    >>
    >>
    >>"carl" <carl@discussions.microsoft.com> wrote in message
    >>news:7CEF6B1D-B90D-49E1-91F5-448278DF6DE4@microsoft.com...
    >>
    >>>I have my data like so:
    >>>
    >>>ColA ColB
    >>>1 A
    >>>1 B
    >>>2 A
    >>>2 B
    >>>1 C
    >>>1 D
    >>>
    >>>Is there a way yo count the number of unique values in ColB if ColA value
    >>>equals 1.
    >>>
    >>>So in the above, the answer would be 4.
    >>>
    >>>Thank you in advance.
    >>>

    >>
    >>
    >>


    --

    [1] The SumProduct function should implicitly coerce the truth values to
    their Excel numeric equivalents.
    [2] The lookup functions should have an optional argument for the return
    value, defaulting to #N/A in its absence.

  46. #46
    K
    Guest

    Re: Counting Unique Values

    Thanks so much for this string, it was exactly the info I needed...

    But - I tried this with my data (4000 rows, one column with values "Include"
    and "Exclude" that is the criteria for counting the unique text values in the
    second column), and ended up with a formula result 1043.4907. Do I round up
    or down???

    =SUMPRODUCT((A2:A3964="Include)/COUNTIF(D2:D3964, D2:D3964&""))

    I don't understand how the formula works or I would troubleshoot it myself

    "Bob Phillips" wrote:

    > =SUMPRODUCT((A1:A20=1)/COUNTIF(B1:B20,B1:B20&""))
    >
    > --
    >
    > HTH
    >
    > RP
    > (remove nothere from the email address if mailing direct)
    >
    >
    > "carl" <carl@discussions.microsoft.com> wrote in message
    > news:7CEF6B1D-B90D-49E1-91F5-448278DF6DE4@microsoft.com...
    > > I have my data like so:
    > >
    > > ColA ColB
    > > 1 A
    > > 1 B
    > > 2 A
    > > 2 B
    > > 1 C
    > > 1 D
    > >
    > > Is there a way yo count the number of unique values in ColB if ColA value
    > > equals 1.
    > >
    > > So in the above, the answer would be 4.
    > >
    > > Thank you in advance.
    > >

    >
    >
    >


  47. #47
    Aladin Akyurek
    Guest

    Re: Counting Unique Values

    Two options...

    {a) If you have the latest version of Longre's morefunc.xll add-in:

    =COUNTDIFF(IF(A2:A15="Include",IF(B2:B15<>"",B2:B15)),FALSE,FALSE)

    which must be confirmed with control+shift+enter, not just with enter.

    (b) With built-in functions:

    =SUMPRODUCT(--(A2:A15="Include"),--(B2:B15<>""),--((MATCH(A2:A15&"#"&B2:B15,A2:A15&"#"&B2:B15,0)=ROW(INDEX(A2:A15,0,0))-ROW(A2)+1)))

    K wrote:
    > Thanks so much for this string, it was exactly the info I needed...
    >
    > But - I tried this with my data (4000 rows, one column with values "Include"
    > and "Exclude" that is the criteria for counting the unique text values in the
    > second column), and ended up with a formula result 1043.4907. Do I round up
    > or down???
    >
    > =SUMPRODUCT((A2:A3964="Include)/COUNTIF(D2:D3964, D2:D3964&""))
    >
    > I don't understand how the formula works or I would troubleshoot it myself
    >
    > "Bob Phillips" wrote:
    >
    >
    >>=SUMPRODUCT((A1:A20=1)/COUNTIF(B1:B20,B1:B20&""))
    >>
    >>--
    >>
    >>HTH
    >>
    >>RP
    >>(remove nothere from the email address if mailing direct)
    >>
    >>
    >>"carl" <carl@discussions.microsoft.com> wrote in message
    >>news:7CEF6B1D-B90D-49E1-91F5-448278DF6DE4@microsoft.com...
    >>
    >>>I have my data like so:
    >>>
    >>>ColA ColB
    >>>1 A
    >>>1 B
    >>>2 A
    >>>2 B
    >>>1 C
    >>>1 D
    >>>
    >>>Is there a way yo count the number of unique values in ColB if ColA value
    >>>equals 1.
    >>>
    >>>So in the above, the answer would be 4.
    >>>
    >>>Thank you in advance.
    >>>

    >>
    >>
    >>


    --

    [1] The SumProduct function should implicitly coerce the truth values to
    their Excel numeric equivalents.
    [2] The lookup functions should have an optional argument for the return
    value, defaulting to #N/A in its absence.

  48. #48
    Aladin Akyurek
    Guest

    Re: Counting Unique Values

    The option (b) can be shorter:

    =SUMPRODUCT(--(A2:A15="Include"),--(B2:B15<>""),--((MATCH(A2:A15&"#"&B2:B15,A2:A15&"#"&B2:B15,0)=ROW(A2:A15)-ROW(A2)+1)))

    I wonder if

    =SUMPRODUCT(--(A2:A15="Include"),--(B2:B15<>""),--ISNUMBER(MATCH(MATCH(A2:A15&"#"&B2:B15,A2:A15&"#"&B2:B15,0),ROW(A2:A15)-ROW(A2)+1,0)))

    would calculate faster.

    Aladin Akyurek wrote:
    > Two options...
    >
    > {a) If you have the latest version of Longre's morefunc.xll add-in:
    >
    > =COUNTDIFF(IF(A2:A15="Include",IF(B2:B15<>"",B2:B15)),FALSE,FALSE)
    >
    > which must be confirmed with control+shift+enter, not just with enter.
    >
    > (b) With built-in functions:
    >
    > =SUMPRODUCT(--(A2:A15="Include"),--(B2:B15<>""),--((MATCH(A2:A15&"#"&B2:B15,A2:A15&"#"&B2:B15,0)=ROW(INDEX(A2:A15,0,0))-ROW(A2)+1)))
    >
    >
    > K wrote:
    >
    >> Thanks so much for this string, it was exactly the info I needed...
    >> But - I tried this with my data (4000 rows, one column with values
    >> "Include" and "Exclude" that is the criteria for counting the unique
    >> text values in the second column), and ended up with a formula result
    >> 1043.4907. Do I round up or down???
    >>
    >> =SUMPRODUCT((A2:A3964="Include)/COUNTIF(D2:D3964, D2:D3964&""))
    >>
    >> I don't understand how the formula works or I would troubleshoot it
    >> myself
    >> "Bob Phillips" wrote:
    >>
    >>
    >>> =SUMPRODUCT((A1:A20=1)/COUNTIF(B1:B20,B1:B20&""))
    >>>
    >>> --
    >>>
    >>> HTH
    >>>
    >>> RP
    >>> (remove nothere from the email address if mailing direct)
    >>>
    >>>
    >>> "carl" <carl@discussions.microsoft.com> wrote in message
    >>> news:7CEF6B1D-B90D-49E1-91F5-448278DF6DE4@microsoft.com...
    >>>
    >>>> I have my data like so:
    >>>>
    >>>> ColA ColB
    >>>> 1 A
    >>>> 1 B
    >>>> 2 A
    >>>> 2 B
    >>>> 1 C
    >>>> 1 D
    >>>>
    >>>> Is there a way yo count the number of unique values in ColB if ColA
    >>>> value
    >>>> equals 1.
    >>>>
    >>>> So in the above, the answer would be 4.
    >>>>
    >>>> Thank you in advance.
    >>>>
    >>>
    >>>
    >>>

    >


    --

    [1] The SumProduct function should implicitly coerce the truth values to
    their Excel numeric equivalents.
    [2] The lookup functions should have an optional argument for the return
    value, defaulting to #N/A in its absence.

  49. #49
    K
    Guest

    Re: Counting Unique Values

    Thanks so much for this string, it was exactly the info I needed...

    But - I tried this with my data (4000 rows, one column with values "Include"
    and "Exclude" that is the criteria for counting the unique text values in the
    second column), and ended up with a formula result 1043.4907. Do I round up
    or down???

    =SUMPRODUCT((A2:A3964="Include)/COUNTIF(D2:D3964, D2:D3964&""))

    I don't understand how the formula works or I would troubleshoot it myself

    "Bob Phillips" wrote:

    > =SUMPRODUCT((A1:A20=1)/COUNTIF(B1:B20,B1:B20&""))
    >
    > --
    >
    > HTH
    >
    > RP
    > (remove nothere from the email address if mailing direct)
    >
    >
    > "carl" <carl@discussions.microsoft.com> wrote in message
    > news:7CEF6B1D-B90D-49E1-91F5-448278DF6DE4@microsoft.com...
    > > I have my data like so:
    > >
    > > ColA ColB
    > > 1 A
    > > 1 B
    > > 2 A
    > > 2 B
    > > 1 C
    > > 1 D
    > >
    > > Is there a way yo count the number of unique values in ColB if ColA value
    > > equals 1.
    > >
    > > So in the above, the answer would be 4.
    > >
    > > Thank you in advance.
    > >

    >
    >
    >


  50. #50
    Aladin Akyurek
    Guest

    Re: Counting Unique Values

    Two options...

    {a) If you have the latest version of Longre's morefunc.xll add-in:

    =COUNTDIFF(IF(A2:A15="Include",IF(B2:B15<>"",B2:B15)),FALSE,FALSE)

    which must be confirmed with control+shift+enter, not just with enter.

    (b) With built-in functions:

    =SUMPRODUCT(--(A2:A15="Include"),--(B2:B15<>""),--((MATCH(A2:A15&"#"&B2:B15,A2:A15&"#"&B2:B15,0)=ROW(INDEX(A2:A15,0,0))-ROW(A2)+1)))

    K wrote:
    > Thanks so much for this string, it was exactly the info I needed...
    >
    > But - I tried this with my data (4000 rows, one column with values "Include"
    > and "Exclude" that is the criteria for counting the unique text values in the
    > second column), and ended up with a formula result 1043.4907. Do I round up
    > or down???
    >
    > =SUMPRODUCT((A2:A3964="Include)/COUNTIF(D2:D3964, D2:D3964&""))
    >
    > I don't understand how the formula works or I would troubleshoot it myself
    >
    > "Bob Phillips" wrote:
    >
    >
    >>=SUMPRODUCT((A1:A20=1)/COUNTIF(B1:B20,B1:B20&""))
    >>
    >>--
    >>
    >>HTH
    >>
    >>RP
    >>(remove nothere from the email address if mailing direct)
    >>
    >>
    >>"carl" <carl@discussions.microsoft.com> wrote in message
    >>news:7CEF6B1D-B90D-49E1-91F5-448278DF6DE4@microsoft.com...
    >>
    >>>I have my data like so:
    >>>
    >>>ColA ColB
    >>>1 A
    >>>1 B
    >>>2 A
    >>>2 B
    >>>1 C
    >>>1 D
    >>>
    >>>Is there a way yo count the number of unique values in ColB if ColA value
    >>>equals 1.
    >>>
    >>>So in the above, the answer would be 4.
    >>>
    >>>Thank you in advance.
    >>>

    >>
    >>
    >>


    --

    [1] The SumProduct function should implicitly coerce the truth values to
    their Excel numeric equivalents.
    [2] The lookup functions should have an optional argument for the return
    value, defaulting to #N/A in its absence.

  51. #51
    Aladin Akyurek
    Guest

    Re: Counting Unique Values

    The option (b) can be shorter:

    =SUMPRODUCT(--(A2:A15="Include"),--(B2:B15<>""),--((MATCH(A2:A15&"#"&B2:B15,A2:A15&"#"&B2:B15,0)=ROW(A2:A15)-ROW(A2)+1)))

    I wonder if

    =SUMPRODUCT(--(A2:A15="Include"),--(B2:B15<>""),--ISNUMBER(MATCH(MATCH(A2:A15&"#"&B2:B15,A2:A15&"#"&B2:B15,0),ROW(A2:A15)-ROW(A2)+1,0)))

    would calculate faster.

    Aladin Akyurek wrote:
    > Two options...
    >
    > {a) If you have the latest version of Longre's morefunc.xll add-in:
    >
    > =COUNTDIFF(IF(A2:A15="Include",IF(B2:B15<>"",B2:B15)),FALSE,FALSE)
    >
    > which must be confirmed with control+shift+enter, not just with enter.
    >
    > (b) With built-in functions:
    >
    > =SUMPRODUCT(--(A2:A15="Include"),--(B2:B15<>""),--((MATCH(A2:A15&"#"&B2:B15,A2:A15&"#"&B2:B15,0)=ROW(INDEX(A2:A15,0,0))-ROW(A2)+1)))
    >
    >
    > K wrote:
    >
    >> Thanks so much for this string, it was exactly the info I needed...
    >> But - I tried this with my data (4000 rows, one column with values
    >> "Include" and "Exclude" that is the criteria for counting the unique
    >> text values in the second column), and ended up with a formula result
    >> 1043.4907. Do I round up or down???
    >>
    >> =SUMPRODUCT((A2:A3964="Include)/COUNTIF(D2:D3964, D2:D3964&""))
    >>
    >> I don't understand how the formula works or I would troubleshoot it
    >> myself
    >> "Bob Phillips" wrote:
    >>
    >>
    >>> =SUMPRODUCT((A1:A20=1)/COUNTIF(B1:B20,B1:B20&""))
    >>>
    >>> --
    >>>
    >>> HTH
    >>>
    >>> RP
    >>> (remove nothere from the email address if mailing direct)
    >>>
    >>>
    >>> "carl" <carl@discussions.microsoft.com> wrote in message
    >>> news:7CEF6B1D-B90D-49E1-91F5-448278DF6DE4@microsoft.com...
    >>>
    >>>> I have my data like so:
    >>>>
    >>>> ColA ColB
    >>>> 1 A
    >>>> 1 B
    >>>> 2 A
    >>>> 2 B
    >>>> 1 C
    >>>> 1 D
    >>>>
    >>>> Is there a way yo count the number of unique values in ColB if ColA
    >>>> value
    >>>> equals 1.
    >>>>
    >>>> So in the above, the answer would be 4.
    >>>>
    >>>> Thank you in advance.
    >>>>
    >>>
    >>>
    >>>

    >


    --

    [1] The SumProduct function should implicitly coerce the truth values to
    their Excel numeric equivalents.
    [2] The lookup functions should have an optional argument for the return
    value, defaulting to #N/A in its absence.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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