+ Reply to Thread
Results 1 to 26 of 26

Using MAX with SUMIFS

Hybrid View

  1. #1
    Registered User
    Join Date
    12-29-2010
    Location
    Cincinnati, Ohio
    MS-Off Ver
    Excel 2007
    Posts
    43

    Using MAX with SUMIFS

    Hi All,

    I am trying to get the max of several data points. I'll explain. I'm looking at three columns..
    1. Building
    2. Cost Center
    3. Number Values for 'x'

    On a different worksheet, I want to SUM the Number Values Column IF it meets 'y' Building AND 'z' Cost Center.

    Here's the twist. There are a total of 30 columns of number values to sum. Using the criteria above, in one formula, I want to get the MAX of the 30 sums that meet the criteria.

    Right now, I have a formula that is not working...

    =MAX(SUMIFS(Number Value Range to sum 1, Building Column, Building, Cost Center Column, Cost Center),(Number Value Range to sum 2, Building Column, Building, Cost Center Column, Cost Center),(Number Value Range to sum 3, Building Column, Building, Cost Center Column, Cost Center), etc.....
    Last edited by NBVC; 01-31-2011 at 04:44 PM.

  2. #2
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Using MAX with SUMIFS

    Try:

    =MAX(IF((Building Column=Building)*(Cost Center Column=Cost Cente),Number Value Range to sum all columns))

    confirmed with CTRL+SHIFT+ENTER
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  3. #3
    Registered User
    Join Date
    12-29-2010
    Location
    Cincinnati, Ohio
    MS-Off Ver
    Excel 2007
    Posts
    43

    Re: Using MAX with SUMIFS

    I will try this. So since I have thirty columns - will I have to do the IF part of the formula 30 times....so the MAX function takes the highest of the 30?

    Thanks!

  4. #4
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,703

    Re: Using MAX with SUMIFS

    Hello Michael,

    Will the max consist of the sum of numbers from a single column in rows where the criteria are met (rather than the sum of maximum number in each row where the criteria is met)? If so try

    =MAX(SUMIFS(OFFSET(Number Value Range to sum 1,0,ROW(INDIRECT("1:30"))-1),Building Column,Building,Cost Center Column,Cost Center))

    assumes that your 30 columns are in a single 30 column range......
    Last edited by daddylonglegs; 01-20-2011 at 12:50 PM.
    Audere est facere

  5. #5
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Using MAX with SUMIFS

    No. You just need to list the whole 30 column range in the last part.

    e.g.

    =MAX(IF(($A$2:$A$100=Building)*($B$2:$B$100=Cost Cente),$C$2:$AD$100))

    just remember to hold the CTRL+SHIFT keys down and hit ENTER to confirm it.

    Edit: Sorry, I think daddylonglegs' is better... mine assumes there is one number in each column that might match, not the sums....
    Last edited by NBVC; 01-20-2011 at 12:52 PM.

  6. #6
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Using MAX with SUMIFS

    Edit: Sorry, I think daddylonglegs' is better... mine assumes there is one number in each column that might match, not the sums....

  7. #7
    Registered User
    Join Date
    12-29-2010
    Location
    Cincinnati, Ohio
    MS-Off Ver
    Excel 2007
    Posts
    43

    Re: Using MAX with SUMIFS

    To answer your question above, the max will consist of numbers from a single column....not the sum in each row where criteria is met.

    I will try what you've recommended... so far, I tried using

    =MAX(IF(($A$2:$A$100=Building)*($B$2:$B$100=Cost Cente),$C$2:$AD$100))

    And it's giving me the #NAME! error

  8. #8
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Using MAX with SUMIFS

    You would have to replace the words Building and Cost Center with cell references containing the search words... or if you want to hard code the search terms enclose them in double quotes...

    BUT... I think what daddylonglegs posted is what you actually need. It looks more like what you are needing... his formula also needs to be confirmed with CTRL+SHIFT+ENTER to work... (you also need to replace the words with actual column/cell references).

  9. #9
    Registered User
    Join Date
    12-29-2010
    Location
    Cincinnati, Ohio
    MS-Off Ver
    Excel 2007
    Posts
    43

    Re: Using MAX with SUMIFS

    Thanks for all the help. Not quite there yet. It's telling me that I have too many arguments... Here is my formula...

    =max(sumifs(offset('All Data'!JO2:JO4996,0,ROW(INDIRECT('All Data'!JO2:'All Data'!KR4674),'All Data'!A2:A4674,"HRNP",'All Data'!X2:X4674,'FT Flex Sliced Info'!D22))))

    Translated:

    =max(sumifs(offset(Sum range 1, 0, ROW(INDIRECT(1 through 30 columns to sum), Building Column, "HRNP", Cost Center Column, Cost Center Reference))))

    What do you recommend?

  10. #10
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Using MAX with SUMIFS

    Try:
    =MAX(SUMIFS(OFFSET('All Data'!JO2:JO4996,0,ROW(INDIRECT("1:30"))-1),'All Data'!A2:A4996,"HRNP",'All Data'!X2:X4996,'FT Flex Sliced Info'!D22))
    Note: the vertical range sizes have to be the same

    Confirm with CTRL+SHIFT+ENTER

  11. #11
    Registered User
    Join Date
    12-29-2010
    Location
    Cincinnati, Ohio
    MS-Off Ver
    Excel 2007
    Posts
    43

    Re: Using MAX with SUMIFS

    Here's what I have and now I'm getting #VALUE!

    =MAX(SUMIFS(OFFSET('All Data'!JO2:JO4674,0,ROW(INDIRECT("1:30"))-1),'All Data'!A:A,"HRNP",'All Data'!X:X,'FT Flex Sliced Info'!D22))

  12. #12
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Using MAX with SUMIFS

    You have different size vertical ranges..

    As I had mentioned, then need to be the same.

    You can't mix JO2:JO4674 to A:A

    make them all range from 2 to 4674, for best efficiency.

  13. #13
    Registered User
    Join Date
    12-29-2010
    Location
    Cincinnati, Ohio
    MS-Off Ver
    Excel 2007
    Posts
    43

    Re: Using MAX with SUMIFS

    I believe that it is working. I do have an error that says "formula omits adjacent cells" - just leave that alone?

    If I want to copy this down, which I tried. It doesn't appear that I can anchor the ranges can I?

    You guys are amazing by the way, truly awesome..

    EDIT - Nevermind on the anchoring - I figured it out. It's been a long day already!

  14. #14
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Using MAX with SUMIFS

    This: "formula omits adjacent cells" is just a warning to advise you that your formula may be missing a column/row of info.. you can just ignore if you know you have covered the ranges you want.

  15. #15
    Registered User
    Join Date
    12-29-2010
    Location
    Cincinnati, Ohio
    MS-Off Ver
    Excel 2007
    Posts
    43

    Re: Using MAX with SUMIFS

    Hi again.

    I'm using the above formula that was suggested by daddylonglegs and I'm finding that I may need to tweak it.

    Without rehashing everything that's been said in the thread....I've manually calculated what the formula is intended to provide - and I'm finding that the formula's output is always short by a few.

    Why could this be?

    Again, I'm trying to get the MAX sum, based upon a set of criteria, from a set of 30 consecutive columns.

  16. #16
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Using MAX with SUMIFS

    Make sure that all the items that are supposed to match your criteria are exact matches. I.e. that there are no leading or trailing spaces in any cells, etc..

    also, ensure that your ranges actually covers the whole lookup table and you aren't short a few rows...

  17. #17
    Registered User
    Join Date
    12-29-2010
    Location
    Cincinnati, Ohio
    MS-Off Ver
    Excel 2007
    Posts
    43

    Re: Using MAX with SUMIFS

    NBVC,

    I've done both. It's strange. Each time a calculate it manually for different ones - it's off by only a few and my formula is giving me a number that is just shy of what is correct based on my manual calculation.

  18. #18
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,703

    Re: Using MAX with SUMIFS

    Quote Originally Posted by michaelweaver4 View Post
    .....it's off by only a few and my formula is giving me a number that is just shy of what is correct based on my manual calculation.
    If any of the numbers are text-formatted they may not be included in the MAX totals, you can check that by using ISNUMBER function, e.g.

    =ISNUMBER(A1)

    will return TRUE only if A1 contains a "true" number

  19. #19
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Using MAX with SUMIFS

    Can you post a sample worksheet showing the disconnect?

  20. #20
    Registered User
    Join Date
    12-29-2010
    Location
    Cincinnati, Ohio
    MS-Off Ver
    Excel 2007
    Posts
    43

    Re: Using MAX with SUMIFS

    For an attempt at greater clarity...

    Give the MAX number from the SUMS of 30 columns of information, if it meets this criteria (building code), and this criteria (cost center).

    So once it meets the criteria (building code then cost center), I want it to sum each of the 30 columns, and give me the max of those sums.

    It helps me to write it out like that a few times...maybe it's helpful!

    Thanks....

  21. #21
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Using MAX with SUMIFS

    I mean attach a sample workbook here.

  22. #22
    Registered User
    Join Date
    12-29-2010
    Location
    Cincinnati, Ohio
    MS-Off Ver
    Excel 2007
    Posts
    43

    Re: Using MAX with SUMIFS

    Quote Originally Posted by NBVC View Post
    I mean attach a sample workbook here.
    I've uploaded an example. There are two workbooks. If you examine cell M3 on the "FT Sliced Info" sheet. When I do those calculations manually (cells KS3:LS3 on the "All Data" sheet) you'll see that 4 is not the max - there is two instances where it's 6.

    Let me know what questions you have. Thanks so much!
    Attached Files Attached Files

  23. #23
    Registered User
    Join Date
    12-29-2010
    Location
    Cincinnati, Ohio
    MS-Off Ver
    Excel 2007
    Posts
    43

    Re: Using MAX with SUMIFS

    I'm going to post a sample file in a moment...

  24. #24
    Registered User
    Join Date
    12-29-2010
    Location
    Cincinnati, Ohio
    MS-Off Ver
    Excel 2007
    Posts
    43

    Re: Using MAX with SUMIFS

    Obviously my attachment is a very small sample of what I'm dealing with...but I think it should be enough to figure out what the formula should be... let me know if not!

  25. #25
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Using MAX with SUMIFS

    You have to confirm the formula with CTRL+SHIFT+ENTER not just ENTER so that { } brackets appear around it... then you will see 6.

  26. #26
    Registered User
    Join Date
    12-29-2010
    Location
    Cincinnati, Ohio
    MS-Off Ver
    Excel 2007
    Posts
    43

    Re: Using MAX with SUMIFS

    Awesome. Thanks so much again....

+ 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