+ Reply to Thread
Results 1 to 8 of 8

SUMIFS, multiple criteria incl. unique values

  1. #1
    Registered User
    Join Date
    06-10-2012
    Location
    South Africa
    MS-Off Ver
    Excel 2019 for Mac
    Posts
    26

    SUMIFS, multiple criteria incl. unique values

    Granted, I have found several formulae that are meant to solve this sort of problem, but as much as I fiddle with it to match my context I can't seem to get an elegant solution. Nor any solution, actually.

    Consider five columns:

    Name # Type Value Activation
    James 0 type1 200 1
    James 1 type3 2 0
    James 2 type1 400 0
    James 3 type2 40 1
    John 0 type1 200 1
    John 4 type3 4 1
    John 2 type1 400 1
    Caitlin 3 type2 40 1
    Caitlin 5 type1 200 1

    The "Name" column isn't really relevant, but it illustrates why I don't have unique values for column "#". Of the values in the "Value" column, I want to sum those that meet the following criteria:

    1. "Type" = type1
    2. "Activation" = 1
    3. The value in "#" is unique (i.e. no double addition).

    So only the second, eighth and tenth rows satisfy the above, returning a sum of 800. Obviously, I'd like the formula to work for a range of values, specifically {type1, type2, ... , typen} for "Type" and {0,1} for "Activation." As long as values with the same "#" aren't summed twice then I'm happy. Until I ran into the double-addition issue I was using this formula, seemingly successfully:

    Please Login or Register  to view this content.
    I've posted this same question here and here. Help would be appreciated.
    Last edited by rinkjames; 06-16-2012 at 04:35 PM.

  2. #2
    Forum Expert RobertMika's Avatar
    Join Date
    06-22-2009
    Location
    Haverhill, UK
    MS-Off Ver
    Excel 2003-13
    Posts
    1,530

    Re: SUMIFS, multiple criteria incl. unique values

    If a helper column is an option
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    06-10-2012
    Location
    South Africa
    MS-Off Ver
    Excel 2019 for Mac
    Posts
    26

    Re: SUMIFS, multiple criteria incl. unique values

    Thanks, it is an option. I'll use that unless someone suggests an alternative.

  4. #4
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,970

    Re: SUMIFS, multiple criteria incl. unique values

    not sure how you arrive at which data samples match, but from what i can see, using your example, data points 1 and 5 match, as do data points 4 and 8. can you confirm this for me please?
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  5. #5
    Registered User
    Join Date
    06-10-2012
    Location
    South Africa
    MS-Off Ver
    Excel 2019 for Mac
    Posts
    26

    Re: SUMIFS, multiple criteria incl. unique values

    By data points do you mean rows? Moving from the top row down, I see only three rows whose values in the "Value" column meet those criteria:

    row 1 Name # Type Value Activation
    row 2 James 0 type1 200 1 this has "type1" and "1" but # is not unique so sum only this value (200)
    row 3 James 1 type3 2 0 this doesn't have "1" nor "type1," so ignore
    row 4 James 2 type1 400 0 this doesn't have "1," so ignore
    row 5 James 3 type2 40 1 this doesn't have "type1," so ignore
    row 6 John 0 type1 200 1 this has "type1" and "1," but # isn't unique (row 2 has the same #), so ignore
    row 7 John 4 type3 4 1 this doesn't have "type1," so ignore
    row 8 John 2 type1 400 1 this has "type1," "1" and though # isn't unique, row 4 is ignored because it has a "0" value, so add 400 to 200 = 600
    row 9 Caitlin 3 type2 40 1 this doesn't have "type1," so ignore
    row 10 Caitlin 5 type1 200 1 this has "type1," "1" and # is unique so add 200 to 600 = 800

    So that's rows 2, 8 and 10, as I see it. Maybe I should have specified that the 3 criteria above should be satisfied in that order, so that if either of the first 2 aren't satisfied, don't bother considering whether # is unique.

  6. #6
    Registered User
    Join Date
    06-10-2012
    Location
    South Africa
    MS-Off Ver
    Excel 2019 for Mac
    Posts
    26

    Re: SUMIFS, multiple criteria incl. unique values

    A nice solution was posted here.

  7. #7
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: SUMIFS, multiple criteria incl. unique values

    With sample data in A2:E10, "Type1" in G1, 1 in G2

    =SUMPRODUCT(IFERROR((C2:C10&E2:E10=G1&G2)/COUNTIFS(B2:B10,B2:B10,C2:C10,G1,E2:E10,G2),0),D2:D10)

    Array confirmed with Shift Ctrl Enter.

  8. #8
    Registered User
    Join Date
    06-10-2012
    Location
    South Africa
    MS-Off Ver
    Excel 2019 for Mac
    Posts
    26

    Re: SUMIFS, multiple criteria incl. unique values

    That also works well, thanks.

+ 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