Forum Discussion

Sushila123's avatar
Sushila123
Copper Contributor
May 23, 2022
Solved

Conditional formula evaluation

Hi,

 

I would like to evaluate a SUMIFS formula so that if it produces a result greater than 0, it should print that value, and if it produces 0, it should instead be an empty field.

What I've currently got is =IF(SUMIFS(...)>0,SUMIFS(...),"") where SUMIFS(...) is short for the full formula.

It works exactly how I want it to, but it seems inefficient to write it twice in an IF formula like that, and then if I ever want to change the criteria I have to do it twice in the same place.

Any suggestions please?

 

Cheers!

4 Replies

  • mathetes's avatar
    mathetes
    Silver Contributor

    Sushila123 

     

    Assuming you have the most recent version of Excel, you could employ the LET function to avoid the redundancy you speak of. Here's a reference.https://exceljet.net/excel-functions/excel-let-function

     

    Given the formula you've shared, =IF(SUMIFS(...)>0,SUMIFS(...),""),

    LET would enable you to write something along these lines:

    =LET(res,SUMIFS(...),IF(res>0,res,""))

  • Sushila123 

    If you keep the original =SUMIFS(...) formula, you have two options:

    • Select File > Options > Advanced. Scroll down to the section "Display options for this worksheet", clear the check box "Show a zero in cells that have zero value" and click OK.
    • Select the cells with the SUMIFS formula, and apply a custom number format to them, for example
      #,##0.00;-#,##0.00;
      The ; at the end effectively hides zero values.
    • mtarler's avatar
      mtarler
      Silver Contributor

      Just a note to go with HansVogelaar solution, if a negative number is possible then change the formula to =MAX( SUMIFS(...), 0)
      and apply either of the bullet points to make the 0 values blank

      but if you have Excel 365 I recommend the LET() command mentioned by mathetes 

Resources