+ Reply to Thread
Results 1 to 19 of 19

Count unique occurrences with sumproduct

  1. #1
    Registered User
    Join Date
    12-26-2012
    Location
    Finland
    MS-Off Ver
    Excel 2010
    Posts
    15

    Post Count unique occurrences with sumproduct

    Hi,

    I have excel 2010 and one function which i could not figure out how to combine with my idea of adding unique occurrence check per row.

    $B5:$B404 (or $B:$B) - is the ratio that may occur duplicates.

    B column
    12-2252533
    12-9542546
    12-9542546
    12-8744031

    in the U6 cell i currently have =SUMPRODUCT(--($J:$J="");--($C:$C="EXTRA")) - i want this function to remain the same but to combine with the occurrence check function.

    above will output sum of 4 to U6, but this should be 3 because i only want one occurrence to count.

    I searched the forum talking about that i should use something like (1/COUNTIF($B:$B;$B:$B)), but this is not correct coding itself.



    Any help is much appreciated! :)
    Last edited by dana26; 01-03-2013 at 04:24 PM.

  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 unique occurrences with sumproduct

    It's not real clear what you're wanting to do.

    Here's my best guess...

    Count unique entries in column B if column J is blank/empty and column C contains "Extra".

    Array entered**:

    =SUM(IF(FREQUENCY(IF(J2:J10="",IF(C2:C10="EXTRA",MATCH(B2:B10,B2:B10,0))),ROW(B2:B10)-ROW(B2)+1),1))

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

    You should avoid using entire columns as range references in array formulas.
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  3. #3
    Registered User
    Join Date
    12-26-2012
    Location
    Finland
    MS-Off Ver
    Excel 2010
    Posts
    15

    Re: Count unique occurrences with sumproduct

    Thanks for quick reply, and yes you got my idea right.

    i had to change the formula little bit because i have excel 2010 which uses semicolons instead of commas.

    =SUM(IF(FREQUENCY(IF(J5:J404="";IF(C5:C404="EXTRA";MATCH(B5:B404;B5:B404;0)));ROW(B5:B404)-ROW(B5)+1);1))

    I never couldn't think it would be so long row of code.

    Thank You.

  4. #4
    Registered User
    Join Date
    12-26-2012
    Location
    Finland
    MS-Off Ver
    Excel 2010
    Posts
    15

    Re: Count unique occurrences with sumproduct

    If possible with conditional formatting,

    can it automatically make foreground color in active cell to standard yellow if that duplicate occurs ?

    I mean yellow from cell A to cell N - which i have data in.


    Thanks again.
    Last edited by dana26; 01-03-2013 at 05:00 PM.

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

    Re: Count unique occurrences with sumproduct

    Yeah, the folks at Microsoft sure didn't make it easy to work with unique entries!

    Thanks for the feedback!

  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 unique occurrences with sumproduct

    If I understand, Excel 2010 conditional formatting has a Duplicates option.

    I don't have Excel 2010 but here are the steps to take in Excel 2007 which should be about the same.

    Select the range of cells in question

    Goto the Home tab>Styles>Conditional Formatting>Highlight Cell Rules>Duplicate Values

  7. #7
    Registered User
    Join Date
    12-26-2012
    Location
    Finland
    MS-Off Ver
    Excel 2010
    Posts
    15

    Re: Count unique occurrences with sumproduct

    I see this impossible with conditional formatting.

    I only want to hightlight if duplicate occurs in row B5:B404 and highlight foreground from only active row, from cell A to cell N


    Cheers.
    Last edited by dana26; 01-03-2013 at 05:28 PM.

  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 unique occurrences with sumproduct

    OK, for that you would need an event macro.

    I'm not much of a programmer so someone else would need to help you with that.

  9. #9
    Registered User
    Join Date
    12-26-2012
    Location
    Finland
    MS-Off Ver
    Excel 2010
    Posts
    15

    Re: Count unique occurrences with sumproduct

    Ok, i'll try to post it to specific forum in here.


    Thanks for your kind help!

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

    Re: Count unique occurrences with sumproduct

    You're welcome!

    Good luck!

  11. #11
    Registered User
    Join Date
    12-26-2012
    Location
    Finland
    MS-Off Ver
    Excel 2010
    Posts
    15

    Re: Count unique occurrences with sumproduct

    Hi again..

    I discovered fault in current condition.

    The problem is that the formula includes row in sum if in B05:B404 have duplicate value and in cell C05:C404 have value inside.

    I would want if formulat do not count into to sum in formula:

    =SUM(IF(FREQUENCY(IF(J5:J404="";IF(C5:C404="EXTRA";MATCH(B5:B404;B5:B404;0)));ROW(B5:B404)-ROW(B5)+1);1))


    ..i think myself somehow C05:C404 cells need to added to MATCH array, but how?

    Any solutions?

  12. #12
    Banned User!
    Join Date
    10-29-2012
    Location
    Europe
    MS-Off Ver
    2013, 2016
    Posts
    318

    Re: Count unique occurrences with sumproduct

    Hi,

    What is range in red??

    Quote Originally Posted by dana26 View Post
    Hi again..

    I discovered fault in current condition.

    The problem is that the formula includes row in sum if in B05:B404 have duplicate value and in cell C05:C404 have value inside.

    I would want if formulat do not count into to sum in formula:

    =SUM(IF(FREQUENCY(IF(J5:J404="";IF(C5:C404="EXTRA";MATCH(B5:B404;B5:B404;0)));ROW(B5:B404)-ROW(B5)+1);1))


    ..i think myself somehow C05:C404 cells need to added to MATCH array, but how?

    Any solutions?

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

    Re: Count unique occurrences with sumproduct

    Sorry, I don't understand.

  14. #14
    Registered User
    Join Date
    12-26-2012
    Location
    Finland
    MS-Off Ver
    Excel 2010
    Posts
    15

    Re: Count unique occurrences with sumproduct

    Sorry, i don't understand myself too. Everything works fine. At first the formula did not change the old values what where already in the table, it functioned properly when newly added values where added to the row B. So it needed just refresh.


    Thanks again.

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

    Re: Count unique occurrences with sumproduct

    Good deal. Thanks for the feedback!

  16. #16
    Registered User
    Join Date
    12-26-2012
    Location
    Finland
    MS-Off Ver
    Excel 2010
    Posts
    15

    Re: Count unique occurrences with sumproduct

    In addition to your first provided function now i would like to count rows where EXTRA and CATEGORY met togheter (row C and row D).


    I made a change to the function but it contains a error inside, i dont know how to fix that

    Modified function with error:
    =SUM(IF(FREQUENCY(IF(J5:J1004="";IF(AND(C5:C1004="EXTRA");D5:D1004="CATEGORY2";MATCH(B5:B1004;B5:B1004;0))));ROW(B5:B1004)-ROW(B5)+1);1))


    Unmodified function:
    =SUM(IF(FREQUENCY(IF(J5:J1004="";IF(C5:C1004="EXTRA";MATCH(B5:B1004;B5:B1004;0)));ROW(B5:B1004)-ROW(B5)+1);1))


    BIG thanks!!
    Last edited by dana26; 02-03-2013 at 11:36 AM.

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

    Re: Count unique occurrences with sumproduct

    Try it like this:

    =SUM(IF(FREQUENCY(IF(J5:J1004="";IF(C5:C1004="EXTRA";IF(D5:D1004="CATEGORY2";MATCH(B5:B1004;B5:B1004;0))));ROW(B5:B1004)-ROW(B5)+1);1))

    Still array entered!

  18. #18
    Registered User
    Join Date
    12-26-2012
    Location
    Finland
    MS-Off Ver
    Excel 2010
    Posts
    15

    Re: Count unique occurrences with sumproduct

    Hey,

    Well done, works perfect!


    Thank Y.

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

    Re: Count unique occurrences with sumproduct

    You're welcome!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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