+ Reply to Thread
Results 1 to 26 of 26

SUMIF trouble with Unique Values & Summing the MAX Values

  1. #1
    Registered User
    Join Date
    12-20-2019
    Location
    Belgium
    MS-Off Ver
    2016
    Posts
    19

    SUMIF trouble with Unique Values & Summing the MAX Values

    Hi All,

    I am trying to get a sum total for ONLY unique Order Totals in Sheet 2, for Unique Name & Week combinations in Sheet 1. For example, for the Cell in Column F, , for all occurences of John week 1 in sheet 1, I need to include the sum of John Week 1 from sheet 2 ONLY ONCE, in an aggregate sum of all other unique name/week combinations as in sheet 1.

    In Column F highlighted green, I need ONE single unique total value of all items from Sheet 1. I suppose this uses some combination of COUNTIF and SUMPRODUCT/SUMIF but i have not figured this out.

    For the example in the sheet for all names, the answer im looking for should be 6200. Not 12400


    i'LL APPRECIATE SOME HELP
    Attached Files Attached Files
    Attached Files Attached Files
    Last edited by AliGW; 05-26-2020 at 03:02 AM. Reason: Title updated to reflect requirements.

  2. #2
    Forum Contributor
    Join Date
    11-10-2017
    Location
    INDIA
    MS-Off Ver
    365
    Posts
    184

    Re: SUMIF trouble with Unique Values

    Hi check this out;

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    *If you wish you click on *,a way to say ThankYou

  3. #3
    Registered User
    Join Date
    12-20-2019
    Location
    Belgium
    MS-Off Ver
    2016
    Posts
    19

    Re: SUMIF trouble with Unique Values

    Hi Thanks for the post. But this doesn't help much as it only counts the number of occurrences for each item

  4. #4
    Forum Expert
    Join Date
    07-06-2004
    Location
    Northern California
    MS-Off Ver
    2K, 2003, 2010, O365
    Posts
    1,490

    Re: SUMIF trouble with Unique Values

    I may be missing something, but how about

    =SUMPRODUCT(INDEX(--(COUNTIF(A4:A9,Sheet2!$A$2:$A$4)*COUNTIF(B4:B9,Sheet2!$B2:$B4)>0),0),Sheet2!$C$2:$C$4)

    in some cell in Sheet1.

  5. #5
    Forum Expert
    Join Date
    09-25-2015
    Location
    Milan Italy
    MS-Off Ver
    office 365
    Posts
    1,788

    Re: SUMIF trouble with Unique Values

    A
    B
    C
    D
    E
    F
    2
    Unique Sum for all Unique Name/week combinations
    3
    Week
    Name Orders
    6200
    4
    1
    John
    5000
    5
    1
    Peter
    200
    6
    1
    Paul
    1000
    7
    1
    John
    5000
    8
    1
    Peter
    200
    9
    1
    Paul
    1000


    F3=SUM(IF( FREQUENCY(IF(C4:C9<>"",IF(A4:A9=A4,C4:C9)),C4:C9),C4:C9))

    control+shift+enter

  6. #6
    Registered User
    Join Date
    12-20-2019
    Location
    Belgium
    MS-Off Ver
    2016
    Posts
    19

    Re: SUMIF trouble with Unique Values

    Quote Originally Posted by hrlngrv View Post
    I may be missing something, but how about

    =SUMPRODUCT(INDEX(--(COUNTIF(A4:A9,Sheet2!$A$2:$A$4)*COUNTIF(B4:B9,Sheet2!$B2:$B4)>0),0),Sheet2!$C$2:$C$4)

    in some cell in Sheet1.
    Wow, this perfectly works! Thank you!

  7. #7
    Registered User
    Join Date
    12-20-2019
    Location
    Belgium
    MS-Off Ver
    2016
    Posts
    19

    Re: SUMIF trouble with Unique Values

    Quote Originally Posted by CARACALLA View Post
    A
    B
    C
    D
    E
    F
    2
    Unique Sum for all Unique Name/week combinations
    3
    Week
    Name Orders
    6200
    4
    1
    John
    5000
    5
    1
    Peter
    200
    6
    1
    Paul
    1000
    7
    1
    John
    5000
    8
    1
    Peter
    200
    9
    1
    Paul
    1000


    F3=SUM(IF( FREQUENCY(IF(C4:C9<>"",IF(A4:A9=A4,C4:C9)),C4:C9),C4:C9))

    control+shift+enter
    I believe this would have worked but it does not link criteria from sheet 1 to sheet 2

  8. #8
    Registered User
    Join Date
    12-20-2019
    Location
    Belgium
    MS-Off Ver
    2016
    Posts
    19

    Re: [SOLVED] SUMIF trouble with Unique Values

    Hi all,

    So coming back to this, I need some help on this same topic. I am now looking to return only the sum of maximum unique order values for all the name/week combinations from sheet 1.

    So essentially F3 in sheet one should add from sheet 2 = 7000 for John + 1000 + 200. 7000 being the max for john.

    I will appreciate any help
    Attached Files Attached Files
    Last edited by visk92; 05-25-2020 at 02:29 PM.

  9. #9
    Registered User
    Join Date
    12-20-2019
    Location
    Belgium
    MS-Off Ver
    2016
    Posts
    19

    Re: SUMIF trouble with Unique Values

    Quote Originally Posted by visk92 View Post
    Wow, this perfectly works! Thank you!
    Please note that my sheet is currently built on this formula. I just need to modify it to pick only max values

  10. #10
    Registered User
    Join Date
    12-20-2019
    Location
    Belgium
    MS-Off Ver
    2016
    Posts
    19

    Re: SUMIF trouble with Unique Values

    Quote Originally Posted by hrlngrv View Post
    I may be missing something, but how about

    =SUMPRODUCT(INDEX(--(COUNTIF(A4:A9,Sheet2!$A$2:$A$4)*COUNTIF(B4:B9,Sheet2!$B2:$B4)>0),0),Sheet2!$C$2:$C$4)

    in some cell in Sheet1.
    Please note that my sheet is currently built on this formula. I just need to modify it to pick only max values

  11. #11
    Registered User
    Join Date
    12-20-2019
    Location
    Belgium
    MS-Off Ver
    2016
    Posts
    19

    Re: [SOLVED] SUMIF trouble with Unique Values

    Any ideas guys?

  12. #12
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,414

    Re: SUMIF trouble with Unique Values

    You have marked the thread as solved ...

    Administrative Note:

    Please don't quote whole posts, especially when you are responding to the one immediately preceding your own - it's just clutter. It's OK to quote if you are responding to a post out of sequence, but limit quoted content to a few relevant lines that makes clear to whom and what you are responding. Thanks!

    For normal conversational replies, try using the QUICK REPLY box below or the REPLY button instead of REPLY WITH QUOTE.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  13. #13
    Registered User
    Join Date
    12-20-2019
    Location
    Belgium
    MS-Off Ver
    2016
    Posts
    19

    Re: SUMIF trouble with Unique Values

    Just marked as unsolved

  14. #14
    Registered User
    Join Date
    12-20-2019
    Location
    Belgium
    MS-Off Ver
    2016
    Posts
    19

    Re: SUMIF trouble with Unique Values

    When I use this formula =SUMPRODUCT(INDEX(--((MAX(COUNTIF(A3:A9,Sheet2!A1:A5))) * (MAX(COUNTIF(B3:B9,Sheet2!B1:B5)))>0),0),MAX(Sheet2!C1:C5)), I get 7000. But the answer should be a total of all max values which is 8200.

    Will appreciate any inputs

  15. #15
    Registered User
    Join Date
    12-20-2019
    Location
    Belgium
    MS-Off Ver
    2016
    Posts
    19

    Re: SUMIF trouble with Unique Values

    Can't believe this is that hard I can clarify if something isn't clear

  16. #16
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,414

    Re: SUMIF trouble with Unique Values

    So you expect somebody to have sorted it out for you overnight, do you? That sort of comment will not endear you to people who are giving freely of their time to help here. Be patient, please.

  17. #17
    Registered User
    Join Date
    12-20-2019
    Location
    Belgium
    MS-Off Ver
    2016
    Posts
    19

    Re: SUMIF trouble with Unique Values

    Oh true, but didn't intend that way.

  18. #18
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,414

    Re: SUMIF trouble with Unique Values

    The original formula does not really work. If you extend the range to cover all rows in Sheet 2 like this:

    =SUMPRODUCT(INDEX(--(COUNTIF(A4:A9,Sheet2!$A$2:$A$5)*COUNTIF(B4:B9,Sheet2!$B2:$B5)>0),0),Sheet2!$C$2:$C$5)

    you will get this: 13200

    I think you need to start again (I don't mean open a new thread!) - in the original query, you seem to want to count the first match for each unique combination on sheet 2 and sum these values - is this correct?
    Last edited by AliGW; 05-26-2020 at 02:36 AM.

  19. #19
    Registered User
    Join Date
    12-20-2019
    Location
    Belgium
    MS-Off Ver
    2016
    Posts
    19

    Re: SUMIF trouble with Unique Values

    Actually this was correct for the initial purpose, and at the time of first posting 13200 will be the answer. But with the new development, I am only looking for the maximum of each unique combination on sheet 2 (so to skip 5k for john and instead add john's max 7k john + 1000 Paul + 200 Peter instead. To do that for every instance where a maximum value exists for each name entry).

    Perhaps I was thinking this could be tweaked using the MAX function somehow. But perhaps you are right, and the entire formula may need to change to get this result

  20. #20
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,414

    Re: SUMIF trouble with Unique Values

    OK - thanks for clarifying.

    When you attach a sample workbook, it needs to (a) contain enough sample data to test solutions properly and (b) contain manually worked out expected results, not a cell with question marks in it.

  21. #21
    Registered User
    Join Date
    12-20-2019
    Location
    Belgium
    MS-Off Ver
    2016
    Posts
    19

    Re: SUMIF trouble with Unique Values

    Alright, noted. Thanks

  22. #22
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,616

    Re: SUMIF trouble with Unique Values & Summing the MAX Values

    What about using a pivot table?
    The Orders are placed in the values field which is summarized by Max
    A Calculated Item is added: =John+Paul +'Peter '
    Let us know if you have any questions.
    Attached Files Attached Files
    Consider taking the time to add to the reputation of everybody that has taken the time to respond to your query.

  23. #23
    Registered User
    Join Date
    12-20-2019
    Location
    Belgium
    MS-Off Ver
    2016
    Posts
    19

    Re: SUMIF trouble with Unique Values & Summing the MAX Values

    Quote Originally Posted by JeteMc View Post
    What about using a pivot table?
    The Orders are placed in the values field which is summarized by Max
    A Calculated Item is added: =John+Paul +'Peter '
    Let us know if you have any questions.


    Thanks for your reply. Under normal circumstances this will work. But the context I'm currently in needs a formula because it is inserted to a cell via a macro. Some other things to note.
    - The data in sheet 1 is already pasted in by a macro from a pivot table

    - The formula is inserted by the same macro in the last phase of the code, in an automated process which picks the week/name combination from sheet 1, match with the max order values for each week/name combination in sheet two and just return the sum of all of these in cell F3.

    With another pivot, it'll be a bit more manual and outside the current design. Nonetheless, thanks for the input

  24. #24
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: SUMIF trouble with Unique Values & Summing the MAX Values

    Hi,

    So week numbers other than 1 are possible? If so, I think it would make sense for you to post a new workbook with a more realistic example together with expected result.

    Regards
    Click * below if this answer helped

    Advanced Excel Techniques: http://excelxor.com/

  25. #25
    Registered User
    Join Date
    12-20-2019
    Location
    Belgium
    MS-Off Ver
    2016
    Posts
    19

    Re: SUMIF trouble with Unique Values & Summing the MAX Values

    Quote Originally Posted by XOR LX View Post
    Hi,

    So week numbers other than 1 are possible? If so, I think it would make sense for you to post a new workbook with a more realistic example together with expected result.

    Regards
    Hi, indeed I might have been a bit unclear with the sample.


    A more representative sample is attached where the problem has been solved with the formula =SUM(IFERROR(MAXIFS(Sheet2!C:C,Sheet2!B:B,Sheet1!$B$4:$B$9,Sheet2!A:A,Sheet1!$A$4:$A$9)/COUNTIFS(A:A,Sheet1!$A$4:$A$9,B:B,Sheet1!$B$4:$B$9),0))

    As you will see in attachments, there can be more than one entry per name/week for each item on sheet 1, and multiple orders for each name/week on sheet 2.
    The formula just picks the max order value of only one of such possible name/week combos from sheet 1 and adds up every such instance for all possible name/week combos available.

    Apparently, it was more of a maxifs/countifs problem and I got some insights to this when I prepared a clearer more representative example. I thought to share here for anyone looking for help with same problem.

    Thanks to everyone who helped out for the time and efforts.
    Attached Files Attached Files

  26. #26
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,616

    Re: SUMIF trouble with Unique Values & Summing the MAX Values

    Shouldn't the sum of the max's per week/name be 31,400?

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Sumif trouble
    By visk92 in forum Hello..Introduce yourself
    Replies: 3
    Last Post: 01-24-2020, 11:35 AM
  2. [SOLVED] Having trouble with my SUMIF formula.
    By LastKryptonian in forum Excel Formulas & Functions
    Replies: 17
    Last Post: 07-21-2015, 04:51 PM
  3. [SOLVED] Having Trouble with SumIf
    By SabbathXXL in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 03-03-2015, 01:17 PM
  4. Trouble with SUMIF
    By hechtic in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 04-30-2014, 02:39 PM
  5. Trouble using =SUMIF
    By slope in forum Excel General
    Replies: 9
    Last Post: 06-11-2009, 04:28 AM
  6. Sumif Trouble
    By dreicer_Jarr in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 04-20-2009, 12:57 PM
  7. Trouble with SUMIF
    By shandy in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 02-08-2007, 04:55 AM

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