+ Reply to Thread
Results 1 to 4 of 4

=sum formula not counting blanks.

  1. #1
    Registered User
    Join Date
    05-09-2013
    Location
    Chicago
    MS-Off Ver
    Excel 2007
    Posts
    2

    =sum formula not counting blanks.

    I am trying to create a a formula where if a cell is blank it don't add it in.

    This is what I have so far.

    =SUM((31-K2),(31-N2),(31-Q2),(31-T2))

    The issue with this is that I am using this cell in an average and if K2,N2,Q2,orT2 is left blank it messes up the overall average.

    Is there a way to get if lets say T2 doesn't have anything in the cell its not automatically adding in 31?

  2. #2
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,731

    Re: =sum formula not counting blanks.

    You could try this approach:

    =SUM((31-K2)*(K2<>""),(31-N2)*(N2<>""),(31-Q2)*(Q2<>""),(31-T2)*(T2<>""))

    Hope this helps.

    Pete

  3. #3
    Registered User
    Join Date
    05-09-2013
    Location
    Chicago
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: =sum formula not counting blanks.

    Fantastic, Thanks Pete. That did just the thing.

    For future knowledge, can you explain what the *(K2<>"") is doing?

  4. #4
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,731

    Re: =sum formula not counting blanks.

    That particular term (and the others that I added) are Boolean expressions, which return TRUE or FALSE. They are sometimes referred to as "implied-IF", as they are equivalent to:

    IF(K2<>"",TRUE,FALSE)

    As the term is multiplying the other term, then TRUE is equivalent to 1 and FALSE equivalent to 0, so essentially we are multiplying (31-K2) by either zero or 1, depending on whether K2 is blank or not. Anything multiplied by zero will give zero, so that term will be ignored in your SUM formula if K2 is blank.

    Hope this helps.

    Pete

+ 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