+ Reply to Thread
Results 1 to 6 of 6

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

Hybrid View

  1. #1
    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.

  2. #2
    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.

  3. #3
    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?

    =IF(COUNTIF($G3:$G27, ">0"), SUMIFS($G3:$G26, $A3:$A26, TODAY(), $H3:$H26, "Admin"), " ")
    Thank you for your help.

+ 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