+ Reply to Thread
Results 1 to 6 of 6

SUMIFS: If no criteria match, leave cell blank, else return value

  1. #1
    Registered User
    Join Date
    11-05-2011
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    56

    SUMIFS: If no criteria match, leave cell blank, else return value

    i'm trying to set up my formula so that if there is no criteria match, rather than returning 0 it leaves the cell blank

    (I recommend skipping the below text and just opening the attached spreadsheet, instructions/what I'm looking for and trying to achieve and well laid out requirements and examples are in the spreadsheet and much more thoroughly explained then I can do below)


    I'm setting up a table that grabs data from columns in a raw data spreadsheet.

    For the purpose of the table I'm making, the formula needs to match up both the House, and the year/month from the raw data sheet, then if the two match and are side by side, return the value to the right either in the Plan Field or the actuals field depending on which field in the table the formula is in. If there is no entry or matching criteria for both the house and Month then it should leave the cell blank, not show a 0

    So I have a SUMIFS formula that I'm trying to set up so that if there is no criteria match it leaves the cell blank.

    So =SUMIFS(sum range, criteria& range, criteria&range), if no matching criteria can be found, leave cell blank, else if matching criteria found then return value from the sumrange.

    This is the exact formula I am using:

    =SUMIFS(INDEX('Raw Data'!$1:$1048576, 0, MATCH(Table!$B9, 'Raw Data'!$1:$1, 0)), INDEX('Raw Data'!$1:$1048576, 0, MATCH(Table!$A$8, 'Raw Data'!$1:$1, 0)), Table!$A$9, INDEX('Raw Data'!$1:$1048576, 0, MATCH(Table!$B$8, 'Raw Data'!$1:$1, 0)), TEXT(Table!C$8, "yyyymm"))

    Yeah kind of hard to follow, so attached is a very detailed and well laid out spreadsheet showing the example of what the formula is, how it's working/what it's returning and an example of what i want it to return/look like, so please check out the spreadsheet, it explains it a million times better.

    Essentially though i want the formula set up so that if there is no criteria match, rather than returning 0 it leaves the cell blank
    Attached Files Attached Files
    Last edited by JTwrk; 11-05-2011 at 01:34 AM.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,150

    Re: SUMIFS: If no criteria match, leave cell blank, else return value

    One way

    =IF(SUMIFS(INDEX('Raw Data'!$1:$1048576, 0, MATCH(Table!$B9, 'Raw Data'!$1:$1, 0)), INDEX('Raw Data'!$1:$1048576, 0, MATCH(Table!$A$8, 'Raw Data'!$1:$1, 0)), Table!$A$9, INDEX('Raw Data'!$1:$1048576, 0, MATCH(Table!$B$8, 'Raw Data'!$1:$1, 0)), TEXT(Table!C$8, "yyyymm"))=0,"",SUMIFS(INDEX('Raw Data'!$1:$1048576, 0, MATCH(Table!$B9, 'Raw Data'!$1:$1, 0)), INDEX('Raw Data'!$1:$1048576, 0, MATCH(Table!$A$8, 'Raw Data'!$1:$1, 0)), Table!$A$9, INDEX('Raw Data'!$1:$1048576, 0, MATCH(Table!$B$8, 'Raw Data'!$1:$1, 0)), TEXT(Table!C$8, "yyyymm")))

    Regards
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    11-05-2011
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    56

    Re: SUMIFS: If no criteria match, leave cell blank, else return value

    Quote Originally Posted by TMShucks View Post
    One way

    =IF(SUMIFS(INDEX('Raw Data'!$1:$1048576, 0, MATCH(Table!$B9, 'Raw Data'!$1:$1, 0)), INDEX('Raw Data'!$1:$1048576, 0, MATCH(Table!$A$8, 'Raw Data'!$1:$1, 0)), Table!$A$9, INDEX('Raw Data'!$1:$1048576, 0, MATCH(Table!$B$8, 'Raw Data'!$1:$1, 0)), TEXT(Table!C$8, "yyyymm"))=0,"",SUMIFS(INDEX('Raw Data'!$1:$1048576, 0, MATCH(Table!$B9, 'Raw Data'!$1:$1, 0)), INDEX('Raw Data'!$1:$1048576, 0, MATCH(Table!$A$8, 'Raw Data'!$1:$1, 0)), Table!$A$9, INDEX('Raw Data'!$1:$1048576, 0, MATCH(Table!$B$8, 'Raw Data'!$1:$1, 0)), TEXT(Table!C$8, "yyyymm")))

    Regards
    Thanks,

    however that removes all 0s even the legitimate ones that should be there.

    I think i figured out something that will work, I'm thinking if i use the countifs function combined with my formula above it will work to not include a 0 if there is no entry for that month.


    =IF(COUNTIFS(INDEX('Raw Data'!$1:$1048576, 0, MATCH(Table!$A$8, 'Raw Data'!$1:$1, 0)), Table!$A$9, INDEX('Raw Data'!$1:$1048576, 0, MATCH(Table!$B$8, 'Raw Data'!$1:$1, 0)), TEXT(Table!C$8, "yyyymm"))=0, "", SUMIFS(INDEX('Raw Data'!$1:$1048576, 0, MATCH(Table!$B9, 'Raw Data'!$1:$1, 0)), INDEX('Raw Data'!$1:$1048576, 0, MATCH(Table!$A$8, 'Raw Data'!$1:$1, 0)), Table!$A$9, INDEX('Raw Data'!$1:$1048576, 0, MATCH(Table!$B$8, 'Raw Data'!$1:$1, 0)), TEXT(Table!C$8, "yyyymm")))


    Checked it all out, seems to work, i'm gonna leave this as unsolved for the moment because i'd like to see if anyone has a shorter or better more elegant solution to it, if it works when i put it in at work next week i'll mark it as solved.

    attached is my updated workbook with the solution if anyone cares.
    Attached Files Attached Files
    Last edited by JTwrk; 11-05-2011 at 04:33 AM.

  4. #4
    Registered User
    Join Date
    03-26-2013
    Location
    Kansas City
    MS-Off Ver
    Excel 2010
    Posts
    1

    Re: SUMIFS: If no criteria match, leave cell blank, else return value

    Here is a potentially easier solution, where everything in [] gets replaced by your specific ranges and criteria cell names:

    =IF(COUNTIF([criteria range], [criteria])>0, SUMIFS([sum range], [criteria range], [criteria]), "")

    example: =IF(COUNTIF(H:H, A2)>0, SUMIFS(I:I, H:H, A2), "")

    This will give you back a blank whenever there isn't a data match to sum, and will help you avoid false zeros.

    The logic here is IF count finds at least one match, THEN add up the items with a match, ELSE return a blank.
    Last edited by KCchristoph; 03-26-2013 at 12:52 PM.

  5. #5
    Forum Contributor
    Join Date
    10-25-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    292

    Re: SUMIFS: If no criteria match, leave cell blank, else return value

    Quote Originally Posted by KCchristoph View Post

    =IF(COUNTIF([criteria range], [criteria])>0, SUMIFS([sum range], [criteria range], [criteria]), "")

    example: =IF(COUNTIF(H:H, A2)>0, SUMIFS(I:I, H:H, A2), "")

    This will give you back a blank whenever there isn't a data match to sum,...
    While I am getting the correct value when there is data that matches the criteria, I am still getting a zero when there isn't anything to sum. Where am I going wrong in the formula?

    Please Login or Register  to view this content.
    Thank you for your help.

  6. #6
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2503 (Windows 11 Home 24H2 64-bit)
    Posts
    90,404

    Re: SUMIFS: If no criteria match, leave cell blank, else return value

    Unfortunately your post does not comply with Rule 2 of our Forum RULES. Do not post a question in the thread of another member -- start your own thread.

    If you feel an existing thread is particularly relevant to your need, provide a link to the other thread in your new thread.

    Old threads are often only monitored by the original participants. New threads not only open you up to all possible participants again, they typically get faster response, too.
    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. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

+ 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