+ Reply to Thread
Results 1 to 11 of 11

Removing Duplicates from SUMPRODUCT

  1. #1
    Registered User
    Join Date
    07-25-2011
    Location
    Midlands, England
    MS-Off Ver
    Excel 2013
    Posts
    32

    Removing Duplicates from SUMPRODUCT

    I have a SUMPRODUCT Formula:

    =SUMPRODUCT(--(NOT(ISBLANK('[file.xls]D1'!$A$15:$A$2000))),--(MONTH('[file.xls]D1'!$G$15:$G$2000)=1),--('[file.xls]D1'!$K$15:$K$2000=5))

    which obviously counts up Column A where Column G equals 1 and Column K equals 5 - and this works fine.

    However, Column A is a reference number and there are duplicates of the reference number in Column A, but I only want to count them just once.

    Can I do this, and how do I do it please?

  2. #2
    Forum Expert Bob Phillips's Avatar
    Join Date
    09-03-2005
    Location
    Wessex
    MS-Off Ver
    Office 2003, 2010, 2013, 2016, 365
    Posts
    3,284

    Re: Removing Duplicates from SUMPRODUCT

    Try this array formula

    =SUM(N(FREQUENCY(IF((NOT(ISBLANK('D1'!$A$15:$A$2000)))*('D1'!$D$15:$D$2000=1)*('D1'!$K$15:$K$2000=5),
    MATCH('D1'!$A$15:$A$2000&"",'D1'!$A$15:$A$2000&"",0)),MATCH('D1'!$A$15:$A$2000&"",'D1'!$A$15:$A$2000&"",0))>0))

  3. #3
    Registered User
    Join Date
    07-25-2011
    Location
    Midlands, England
    MS-Off Ver
    Excel 2013
    Posts
    32

    Re: Removing Duplicates from SUMPRODUCT

    File.xls points to an external reference, hence why I had that bit extra in the formula. When I add this back in, I get:

    =SUM(N(FREQUENCY(IF((NOT(ISBLANK('[file.xls]District 1'!$A$15:$A$2000)))*('[file.xls]District 1'!$D$15:$D$2000=1)*('[file.xls]District 1'!$K$15:$K$2000=5),MATCH('[file.xls]District 1'!$A$15:$A$2000&"",'[file.xls]District 1'!$A$15:$A$2000&"",0)),MATCH('[file.xls]District 1'!$A$15:$A$2000&"",'[file.xls]District 1'!$A$15:$A$2000 &"",0))>0))

    Unfortunately, this is giving me #VALUE errors. But the original formula posted does still work. Hmmmm...

    Additionally, will this work when the externally referenced file is closed? - as this is a requirement.
    Last edited by highguyuk; 07-27-2012 at 06:25 AM.

  4. #4
    Forum Expert Bob Phillips's Avatar
    Join Date
    09-03-2005
    Location
    Wessex
    MS-Off Ver
    Office 2003, 2010, 2013, 2016, 365
    Posts
    3,284

    Re: Removing Duplicates from SUMPRODUCT

    Did you array enter it, Ctrl_Shift-Enter?

  5. #5
    Registered User
    Join Date
    07-25-2011
    Location
    Midlands, England
    MS-Off Ver
    Excel 2013
    Posts
    32

    Re: Removing Duplicates from SUMPRODUCT

    No - I didn't realise there was an array enter! Not used this side of Excel before, still learning! For example, I have no idea why I had the MONTH value in my original formula! That now works with the expected value.

    However I now have added an additional array of Column G, which has thrown it and now gives me a value of 0.

    =SUM(N(FREQUENCY(IF((NOT(ISBLANK('[file.xls]District 1'!$A$15:$A$2000)))*('[file.xls]District 1'!$D$15:$D$2000=1)*('[file.xls]District 1'!$G$15:$G$2000=1)*('[file.xls]District 1'!$K$15:$K$2000=5),
    MATCH('[file.xls]District 1'!$A$15:$A$2000&"",'[file.xls]District 1'!$A$15:$A$2000&"",0)),MATCH('[file.xls]District 1'!$A$15:$A$2000&"",'[file.xls]District 1'!$A$15:$A$2000&"",0))>0))

  6. #6
    Forum Expert Bob Phillips's Avatar
    Join Date
    09-03-2005
    Location
    Wessex
    MS-Off Ver
    Office 2003, 2010, 2013, 2016, 365
    Posts
    3,284

    Re: Removing Duplicates from SUMPRODUCT

    That would suggest that no rows satisfy all of the criteria.

  7. #7
    Registered User
    Join Date
    07-25-2011
    Location
    Midlands, England
    MS-Off Ver
    Excel 2013
    Posts
    32

    Re: Removing Duplicates from SUMPRODUCT

    Agreed - but there are rows that satisfy the criteria. I just wanted to make sure the additional criteria in the formula was correct, which I think it is. I'll need to work the next bit out I suppose!

  8. #8
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Removing Duplicates from SUMPRODUCT

    Not to sure where you are with this, but using a helper column might be easier on memory than array formulae.

    The helper formula might also be easier to understand and modify.

    See this workbook
    Attached Files Attached Files
    If you need any more information, please feel free to ask.

    However,If this takes care of your needs, please select Thread Tools from menu above and set this topic to SOLVED. It helps everybody! ....

    Also
    اس کی مدد کرتا ہے اگر
    شکریہ کہنے کے لئے سٹار کلک کریں
    If you are satisfied by any members response to your problem please consider using the small Star icon bottom left of their post to show your appreciation.

  9. #9
    Registered User
    Join Date
    07-25-2011
    Location
    Midlands, England
    MS-Off Ver
    Excel 2013
    Posts
    32

    Re: Removing Duplicates from SUMPRODUCT

    Still working on this, thanks for your assistance so far.

    Marcol, either I’m slightly confused by the attached spread sheet and reading it wrong or I think this goes some way to achieving the opposite of what I’m trying to do. For example in Cell P24, it adds up all those with Code 5 to get the figure 4. Yet the formula I want would add up all the Code 5s within a larger criteria, but still add up to 1.

    ---------- Post added at 04:17 PM ---------- Previous post was at 03:36 PM ----------

    I’m struggling with adding an additional filter to this formula:
    =SUM(N(FREQUENCY(IF((NOT(ISBLANK('[File.xls]District 1'!$A$15:$A$2000)))*('[File.xls]District 1'!$D$15:$D$2000=1)*('[File.xls]District 1'!$K$15:$K$2000=5),MATCH('[File.xls]District 1'!$A$15:$A$2000&"",'[File.xls]District 1'!$A$15:$A$2000&"",0)),MATCH('[File.xls]District 1'!$A$15:$A$2000&"",'[File.xls]District 1'!$A$15:$A$2000 &"",0))>0))

    The above formula works as it should do and removes duplicates as expected. I now want to add an additional filter on column G, where G will be equal 1. To do this, I’ve tried this:

    =SUM(N(FREQUENCY(IF((NOT(ISBLANK('[File.xls]District 1'!$A$15:$A$2000)))*('[File.xls]District 1'!$G$15:$G$2000=1)*('[File.xls]District 1'!$D$15:$D$2000=1)*('[File.xls]District 1'!$K$15:$K$2000=5),MATCH('[File.xls]District 1'!$A$15:$A$2000&"",'[File.xls]District 1'!$A$15:$A$2000&"",0)),MATCH('[File.xls]District 1'!$A$15:$A$2000&"",'[File.xls]District 1'!$A$15:$A$2000 &"",0))>0))

    But this additional part doesn’t work. How do I add the additional criteria?
    Last edited by highguyuk; 07-31-2012 at 11:20 AM.

  10. #10
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: Removing Duplicates from SUMPRODUCT

    Your revised formula syntax is fine - that works for me on test data. What's in column G, are they dates, is it a formula? Your original formula used MONTH function against that column
    Audere est facere

  11. #11
    Registered User
    Join Date
    07-25-2011
    Location
    Midlands, England
    MS-Off Ver
    Excel 2013
    Posts
    32

    Re: Removing Duplicates from SUMPRODUCT

    Quote Originally Posted by daddylonglegs View Post
    Your revised formula syntax is fine - that works for me on test data. What's in column G, are they dates, is it a formula? Your original formula used MONTH function against that column
    Thank you for verifying. :-)

    I found an error with Column G, which although was Formatted as Number was giving an error as a number as text? Anyway, just needed to convert it to a true number and it's worked. So pleased.

    I've added appropriate Stars etc, thanks all again.

+ 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