+ Reply to Thread
Results 1 to 11 of 11

SUMIFS - ">" or "<"

  1. #1
    Registered User
    Join Date
    07-12-2005
    Location
    Canberra, Australia
    MS-Off Ver
    2007
    Posts
    43

    SUMIFS - ">" or "<"

    Hi,

    I am having problems with a SUMIFS formula whereby the formula references a column which is either "<=21" or ">21". Just to give it some context - this relates to the number of days a patient is in hospital.
    The formula works for "<=21", but not for ">21".
    It will make more sense when you open the file.

    Does anyone know why the formula does not work?

    Many thanks
    David
    Attached Files Attached Files

  2. #2
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: SUMIFS - ">" or "<"

    No. I cannot tell why it does not. It doesn't appear to be a character set issue because MATCH and VLOOKUP work fine.

    In the meantime if you need something to do the job try this
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Edit Standby. I'll see if I can get us some help.
    Last edited by FlameRetired; 02-17-2016 at 11:08 PM.
    Dave

  3. #3
    Registered User
    Join Date
    07-12-2005
    Location
    Canberra, Australia
    MS-Off Ver
    2007
    Posts
    43

    Re: SUMIFS - ">" or "<"

    Thanks Dave. My actual formula has other criteria, which is why I didn't use the VLOOKUP function. I just wanted to simplify it when I posted my question. Thanks for replying though.

  4. #4
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: SUMIFS - ">" or "<"

    Hold on. I see the problem. SUMIFS is interpreting the text of C4 the same as if you had entered =SUMIFS(K:K,J:J,">"&C4). That means it is trying to compare a number value 21 to a text value in J:J whose value is 0. 0 of course is not greater than 21.

    It works for C3 because the syntax ≤ 21 is not evaluated as <=. To Excel it is just some more text that finds a match in J:J. You can demonstrate this by changing the formula in C3 to =IF(B3>21,"> 21","<= 21") and the entry in J3 to <=21. Now D3 also returns a 0 instead of 20.

    You'll need a different approach to get SUMIFS to work here. Since I don't see the larger picture I'm not of much help there. Hopefully this will give you some ideas.
    Last edited by FlameRetired; 02-18-2016 at 12:02 AM.

  5. #5
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: SUMIFS - ">" or "<"

    DD1,

    An afterthought.

    Try changing the formula in C3:C4 to =IF(B3>21,"#> 21","≤ 21") (or with some more suitable extra leading character before the > 21). Then change J4 to #> 21. Your formula works now.

  6. #6
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: SUMIFS - ">" or "<"

    This formula should work fine with your original setup

    In D3 and copy down

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Adjust ranges as needed.
    If you like my answer please click on * Add Reputation
    Don't forget to mark threads as "Solved" if your problem has been resolved

    "Nothing is so firmly believed as what we least know."
    --Michel de Montaigne

  7. #7
    Registered User
    Join Date
    07-12-2005
    Location
    Canberra, Australia
    MS-Off Ver
    2007
    Posts
    43

    Re: SUMIFS - ">" or "<"

    Thank you Alkey. That's a very neat solution.

    My actual spreadsheet/formula though requires 2 criteria. I have modified my spreadsheet and re-attached it. Would you mind taking another look? I did have a go myself without success unfortunately.

    It also has in excess of 400,000 rows. Does that make any difference to the Excel functions that you would use - i.e. are some more efficient than others?

    Many thanks
    David
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    07-12-2005
    Location
    Canberra, Australia
    MS-Off Ver
    2007
    Posts
    43

    Re: SUMIFS - ">" or "<"

    Thanks Dave. That is an alternative and I may end up doing that. Alkey was able to use the SUM and INDEX functions which I like, but I have 2 criteria and wasn't able to modify his formula to include the additional criteria. I have re-attached the spreadsheet with the additional column. Hopefully he will be able to modify it for me. If not, I will use your solution.
    Thanks for taking the time to look at it.
    Regards,
    David

  9. #9
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: SUMIFS - ">" or "<"

    Piggybacking on AlKey's formula add the new criteria by making this adjustment.

    Formula: copy to clipboard
    Please Login or Register  to view this content.

  10. #10
    Registered User
    Join Date
    07-12-2005
    Location
    Canberra, Australia
    MS-Off Ver
    2007
    Posts
    43

    Re: SUMIFS - ">" or "<"

    Thanks to both of you for your help. That worked brilliantly.
    Really appreciate it.
    David

  11. #11
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: SUMIFS - ">" or "<"

    You're welcome. Glad to help. Thanks for the feedback and rep.

+ 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. Replies: 1
    Last Post: 01-22-2016, 09:21 AM
  2. Replies: 1
    Last Post: 08-15-2014, 06:00 AM
  3. Replies: 4
    Last Post: 11-17-2013, 12:05 PM
  4. [SOLVED] How to USE """"" cells count """"" change font color
    By austin123456 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-09-2013, 06:14 AM
  5. Replies: 5
    Last Post: 10-12-2010, 06:46 AM
  6. Replies: 5
    Last Post: 06-26-2006, 09:23 PM
  7. Replies: 7
    Last Post: 05-13-2006, 05:02 PM

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